我从苹果公司获得了我的应用程序崩溃报告,因为有一些nspathstore2漏洞导致崩溃,现在我发现在阅读报告后很难在代码中找到错误,这里是我的报告
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x31071f7e objc_msgSend + 22
1 Foundation 0x35ba2210 -[NSPathStore2 stringByAppendingPathComponent:] + 84
2 Photobook 0x000131d0 0x1000 + 74192
3 Photobook 0x0001333c 0x1000 + 74556
4 Photobook 0x000138a2 0x1000 + 75938
5 Photobook 0x0001200c 0x1000 + 69644
6 Photobook 0x000113ac 0x1000 + 66476
7 UIKit 0x36fc30b6 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 142
8 CoreFoundation 0x36ca51f4 -[NSObject performSelector:withObject:] + 36
9 QuartzCore 0x36481a9e -[CALayer layoutSublayers] + 210
10 QuartzCore 0x364816b6 CA::Layer::layout_if_needed(CA::Transaction*) + 210
11 QuartzCore 0x3648583c CA::Context::commit_transaction(CA::Transaction*) + 220
12 QuartzCore 0x36485578 CA::Transaction::commit() + 308
13 QuartzCore 0x3647d4b2 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 50
14 CoreFoundation 0x36d1ab14 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 12
15 CoreFoundation 0x36d18d50 __CFRunLoopDoObservers + 252
16 CoreFoundation 0x36d190aa __CFRunLoopRun + 754
17 CoreFoundation 0x36c9c49e CFRunLoopRunSpecific + 294
18 CoreFoundation 0x36c9c366 CFRunLoopRunInMode + 98
19 GraphicsServices 0x30d7e432 GSEventRunModal + 130
20 UIKit 0x36fede76 UIApplicationMain + 1074
21 Photobook 0x0000229c 0x1000 + 4764
22 Photobook 0x00002254 0x1000 + 4692
现在我假设这个“1基金会0x35ba2210 - [NSPathStore2 stringByAppendingPathComponent:] + 84”说明崩溃是在项目某处的第84行,所以我试图找到这个,但是没有stringByAppendingPathComponent:用于第84行项目中的任何地方,所以我很困惑如何在项目中找到泄漏,任何人都可以指导如何找到这个,而不是考虑。萨德
答案 0 :(得分:2)
问题:
- [NSPathStore2 length]:无法识别的选择器发送到实例0x80cea00
当您的应用程序崩溃时, NSPathStore2 通知它是否包含上面的任何方法,它包含“长度”,那么请将我的解决方案放在其工作正常的下方,我希望它也适合您。:)< / p>
解决方案:上述错误消息表示您的“ PATH ”对象变量存在问题。我将通过以下给定示例向您解释: 让我们考虑您在.m文件中定义下面的代码需要定义的任何方法。“ dbpath ”是一个 NSString 类变量,它定义在。 h file。现在您将完成路径存储在“ dbpath ”变量中,如下面的示例所示。现在,当您要在.m文件中的任何其他方法中使用此“ dbpath ”变量时,它会因上面的消息“ - [ NSPathStore2 长度”而崩溃]:无法识别的选择器发送到实例0x80cea00 “因为您没有” alloc “或”保留“” dbpath “ 。因此,在下面给出的示例中,请解决此问题的方法是 alloc 或保留“ dbpath ”变量。 这是我的答案,当我把它崩溃并为我做好工作时。最好的你:)) NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES); NSString * path = [paths objectAtIndex:0]; dbpath = [path stringByAppendingPathComponent:@“mydb.sqlite”];