How can I remove all of the photos that I've saved in NSHomeDirectory
? They are photos, saved in a path formatted as follows" /var/mobile/Applications/3EEDBD68-5496-458D-9EF0-062746847C83/Photos/1234.png
.
And what do I call if I only want to remove a certain photo (ie that 1234.png listed above)?
请参阅NSFileManager 。
To remove one item, you could call:
NSString *filePath = @"/var/mobile/Applications/3EEDBD68-5496-458D-9EF0-062746847C83/Photos/1234.png";
[[NSFileManager defaultManager] removeItemAtPath:filePath error:&error];
To remove all of them:
NSString *directoryPath = @"/var/mobile/Applications/3EEDBD68-5496-458D-9EF0-062746847C83/Photos/";
[[NSFileManager defaultManager] removeItemAtPath:directoryPath error:&error];
// Re-create the directory
[[NSFileManager defaultManager] createDirectoryAtPath:directoryPath withIntermediateDirectories:YES attributes:nil error:&error];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.