gpt4 book ai didi

iphone - 删除 iPhone 沙箱(文档文件夹)中的所有文件?

转载 作者:IT王子 更新时间:2023-10-29 07:36:50 26 4
gpt4 key购买 nike

有没有一种简单的方法可以删除我保存在应用程序文档文件夹中的所有文件(图像)?

最佳答案

NSFileManager *fileMgr = [[[NSFileManager alloc] init] autorelease];
NSError *error = nil;
NSArray *directoryContents = [fileMgr contentsOfDirectoryAtPath:documentsDirectory error:&error];
if (error == nil) {
for (NSString *path in directoryContents) {
NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:path];
BOOL removeSuccess = [fileMgr removeItemAtPath:fullPath error:&error];
if (!removeSuccess) {
// Error handling
...
}
}
} else {
// Error handling
...
}

关于iphone - 删除 iPhone 沙箱(文档文件夹)中的所有文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4793278/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com