gpt4 book ai didi

iphone - -[NSFileManager removeItemAtPath :error:] makes app CRASH

转载 作者:行者123 更新时间:2023-11-28 20:42:49 26 4
gpt4 key购买 nike

尝试在启动时删除文件夹时出现错误。我们正在删除放置在用于存储缓存数据的文档中的文件夹。知道为什么它会崩溃吗?

0   libsystem_kernel.dylib  0x364b62d0 __unlink + 8
1 libsystem_kernel.dylib 0x364b46a6 unlink + 2
2 libremovefile.dylib 0x313099c8 __removefile_process_file + 232
3 libremovefile.dylib 0x31309a50 __removefile_tree_walker + 100
4 libremovefile.dylib 0x313090f4 removefile + 88
5 Foundation 0x3156c11a -[NSFilesystemItemRemoveOperation main] + 138
6 Foundation 0x31551d14 -[__NSOperationInternal start] + 652
7 Foundation 0x31551a78 -[NSOperation start] + 16
8 Foundation 0x3156bfda -[NSFileManager removeItemAtPath:error:] + 46
9 VG 0x0004f030 +[VGFileManager removeOldCacheFolder] + 319536
10 VG 0x00003e1c -[VGAppDelegate application:didFinishLaunchingWithOptions:] + 11804
11 UIKit 0x31de481a -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 766
12 UIKit 0x31ddeb5e -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 266
13 UIKit 0x31db37d0 -[UIApplication handleEvent:withNewEvent:] + 1108
14 UIKit 0x31db320e -[UIApplication sendEvent:] + 38
15 UIKit 0x31db2c4c _UIApplicationHandleEvent + 5084
16 GraphicsServices 0x34720e70 PurpleEventCallback + 660
17 CoreFoundation 0x30ba5a90 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 20
18 CoreFoundation 0x30ba7838 __CFRunLoopDoSource1 + 160
19 CoreFoundation 0x30ba8606 __CFRunLoopRun + 514
20 CoreFoundation 0x30b38ebc CFRunLoopRunSpecific + 224
21 CoreFoundation 0x30b38dc4 CFRunLoopRunInMode + 52
22 UIKit 0x31dddd42 -[UIApplication _run] + 366
23 UIKit 0x31ddb800 UIApplicationMain + 664
24 VG 0x0000bd96 0x1000 + 44438
25 VG 0x00003990 0x1000 + 10640

这是在“9”上调用的函数。

+ (void)removeOldCacheFolder {

BOOL oldCacheFolderRemoved = [[NSUserDefaults standardUserDefaults] boolForKey:kVGFileCacheFolder_1_2];

if(!oldCacheFolderRemoved){
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; //Get documents folder
NSString *cacheDirectory = [documentsDirectory stringByAppendingPathComponent:kVGFileCacheFolder_1_2];

if ([[NSFileManager defaultManager] fileExistsAtPath:cacheDirectory]) {
NSError *error = nil;

if (!([[NSFileManager defaultManager] removeItemAtPath:cacheDirectory error:&error])) {
ELog(@"Unresolved error %@, %@", error, [error userInfo]);
}
else{
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:kVGFileCacheFolder_1_2];
}
}
}

BOOL oldSQLFileDeleted = [[NSUserDefaults standardUserDefaults] boolForKey:kVGFileDb_1_3];

if(!oldSQLFileDeleted){

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; //Get documents folder

NSString *sqlFile = [documentsDirectory stringByAppendingPathComponent:kVGFileDb_1_3];

if ([[NSFileManager defaultManager] fileExistsAtPath:sqlFile]) {
NSError *error = nil;

if (!([[NSFileManager defaultManager] removeItemAtPath:sqlFile error:&error])) {
ELog(@"Unresolved error %@, %@", error, [error userInfo]);
}
else{
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:kVGFileDb_1_3];
}
}
}
}

编辑:刚刚发现这个过程可能需要 2 分钟...

最佳答案

也许我们正在被 iOS 看门狗杀死,任何启动时间过长的应用程序都会被终止。这会不会是一个太耗时的过程?

关于iphone - -[NSFileManager removeItemAtPath :error:] makes app CRASH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7753838/

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