简体   繁体   English

从Nsdocument目录中删除数据

[英]Delete Data from Nsdocument Directory

How can i delete data from NSDocumentDirectory which i have saved using the following code. 如何使用以下代码从NSDocumentDirectory中删除已保存的数据。

 NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
 NSString *documentsDirectory = [paths objectAtIndex:0];
 NSString *fullFileName2 = [NSString stringWithFormat:@"%@nameArray", documentsDirectory];
 nameArray=[[NSMutableArray alloc]initWithContentsOfFile:fullFileName2];

 [nameArray addObject:nameField.text];
 [nameArray writeToFile:fullFileName2 atomically:NO];

try this : 尝试这个 :

NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);  

NSString *documentsDirectory = [paths objectAtIndex:0]; 

NSString *fullFileName2 = [NSString stringWithFormat:@"%@nameArray", documentsDirectory]; 

[[NSFileManager defaultManager] removeItemAtPath:fullFileName2 error: NULL];    

Try this, 尝试这个,

 NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
 NSString *documentsDirectory = [paths objectAtIndex:0];
 NSString *fullFileName2 = [nameArray objectAtIndex:0];
 [[NSFileManager defaultManager] removeItemAtPath:fullFileName2 error: NULL];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM