I want my app to delete all the information it has saved to the device, and i was told you do this using the NSFile Manager, so i was wondering what the code was to do this?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Simple ,
folderPath is the path of your Document Directory.
NSString *folderPath;
NSArray *dirContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:folderPath error:&error];
for (NSString *strName in dirContents) {
[[NSFileManager defaultManager] removeItemAtPath:[folderPath stringByAppendingPathComponent:strName] error:&error];
}
Hope it will be helpful to you