IOS, delete all data stored on the device using NSFileManager

I want my application to delete all the information stored on the device, and I was told that you are doing this using NSFile Manager, so I was wondering what this code should have done?

-1
source share
1 answer

Plain,

folderPath is the path to 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 for you.

+2
source

Source: https://habr.com/ru/post/1259903/


All Articles