问题
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
来源:https://stackoverflow.com/questions/9358484/ios-delete-all-data-saved-to-device-by-app-using-nsfilemanager