Core Data 导致 iPhone 3 崩溃
我在核心数据方面遇到了一个奇怪的错误。有时,但并非总是,当我尝试访问核心数据对象时,我的应用程序会崩溃。
iPhone 3 上经常出现这种情况,iPhone 4 上偶尔会出现这种情况。我查看了我的设备日志,并将其范围缩小到核心数据的问题。日志引用的行如下,tripInstructor 是一个核心数据对象,它是 AppManager 类的一个属性。不确定这是否有很大的不同,但我确实声明该属性是“非原子的,保留”。
感谢您的任何建议
[self.supervisorLbl setText:[AppManager sharedAppManager].tripInstructor.name];
Date/Time: 2011-06-12 20:55:24.865 +1000
OS Version: iPhone OS 4.3.3 (8J2)
Report Version: 104
异常类型:EXC_CRASH(SIGABRT)
异常代码:0x00000000、0x00000000
崩溃线程:0
线程 0 名称:调度队列:com.apple.main-thread
线程 0 崩溃:
0 libsystem_kernel.dylib 0x33e8da1c pthread_kill + 8
1 libsystem_c.dylib 0x35e5b3b4 pthread_kill + 52
2 libsystem_c.dylib 0x35e53bf8 中止 + 72
3 libstdc++.6.dylib 0x33508a64 __gnu_cxx::__verbose_terminate_handler() + 376
4 libobjc.A.dylib 0x33f1106c _objc_终止 + 104
5 libstdc++.6.dylib 0x33506e36 _cxxabiv1::_terminate(void (*)()) + 46
6 libstdc++.6.dylib 0x33506e8a std::terminate() + 10
7 libstdc++.6.dylib 0x33506efe __cxa_rethrow + 62
8 libobjc.A.dylib 0x33f10fd8 objc_异常_重新抛出 + 4
9 核心数据 0x35624f66 _PFFaultHandlerLookupRow + 1450
10 CoreData 0x356799ba -[NSFaultHandler fillFault:withContext:] + 14
11 核心数据 0x35678782 _PF_FulfillDeferredFault + 354
12 核心数据 0x35623f18 _sharedIMPL_pvfk_core + 52
13 核心数据 0x35626b68 _pvfk_5 + 4
14 eLogger 0x0000e346 -[VicLogVC viewWillAppear:] (VicLogVC.m:207)
15 UIKit 0x3636bf14 -[UINavigationController _startTransition:fromViewController:toViewController:] + 604
16 UIKit 0x3636bc3c -[UINavigationController _startDeferredTransitionIfNeeded] + 176
17 UIKit 0x3635dd56 -[UINavigationController PushViewController:过渡:forceImmediate:] + 634
18 UIKit 0x3635dacc -[UINavigationController PushViewController:动画:] + 28
19 eLogger 0x00025332 -[TripScreenVC _populateAndDisplayVicLog] (TripScreenVC.m:221)
20 eLogger 0x00025492 -[TripScreenVC _defineLogScreen] (TripScreenVC.m:258)
21 eLogger 0x000255d4 -[TripScreenVC 按钮按下:] (TripScreenVC.m:307)
22 CoreFoundation 0x30d4356a -[NSObject(NSObject) PerformSelector:withObject:withObject:] + 18
23 UIKit 0x36343ec2 -[UIApplication sendAction:to:from:forEvent:] + 78
24 UIKit 0x36343e62 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 26
25 UIKit 0x36343e34 -[UIControl sendAction:to:forEvent:] + 32
26 UIKit 0x36343b86 -[UIControl(内部)_sendActionsForEvents:withEvent:] + 350
27 UIKit 0x3634441c -[UIControl TouchsEnded:withEvent:] + 336
28 UIKit 0x36342bee - [UIWindow _sendTouchesForEvent:] + 362
29 UIKit 0x36342568 - [UIWindow发送事件:] + 256
30 UIKit 0x3632b30c -[UIApplication 发送事件:] + 292
31 UIKit 0x3632ac4c _UIApplicationHandleEvent + 5084
32 图形服务 0x34e2be70 PurpleEventCallback + 660
33 CoreFoundation 0x30daaa90 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 20
34 核心基础 0x30dac838 __CFRunLoopDoSource1 + 160
35 核心基础 0x30dad606 __CFRunLoopRun + 514
36 核心基础 0x30d3debc CFRunLoopRunSpecific + 224
37 核心基础 0x30d3ddc4 CFRunLoopRunInMode + 52
38 图形服务 0x34e2b418 GSEventRunModal + 108
39 图形服务 0x34e2b4c4 GSEventRun + 56
40 UIKit 0x36355d62-[UIApplication_run] + 398
41 UIKit 0x36353800 UIApplicationMain + 664
42 eLogger 0x00002ff8 main (main.m:14)
43 eLogger 0x00002fa0开始+32
I'm getting a strange error with core data. Sometimes, but not all the time my app will crash when I try to access a core data object.
It happens regularly on iPhone 3's and only sometimes on iPhone 4's. I looked at my device log and narrowed it down to an issue with core data. The line the logs refer to is below, tripInstructor is a core data object, its a property of the AppManager class. Not sure if this makes a big difference but I do declare the property as being "nonatomic, retain".
Thanks for any advice
[self.supervisorLbl setText:[AppManager sharedAppManager].tripInstructor.name];
Date/Time: 2011-06-12 20:55:24.865 +1000
OS Version: iPhone OS 4.3.3 (8J2)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x00000000, 0x00000000 Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 libsystem_kernel.dylib 0x33e8da1c pthread_kill + 8 1 libsystem_c.dylib 0x35e5b3b4 pthread_kill + 52 2 libsystem_c.dylib 0x35e53bf8 abort + 72 3 libstdc++.6.dylib 0x33508a64 __gnu_cxx::__verbose_terminate_handler() + 376 4 libobjc.A.dylib 0x33f1106c _objc_terminate + 104 5 libstdc++.6.dylib 0x33506e36 _cxxabiv1::_terminate(void (*)()) + 46 6 libstdc++.6.dylib 0x33506e8a std::terminate() + 10 7 libstdc++.6.dylib 0x33506efe __cxa_rethrow + 62 8 libobjc.A.dylib 0x33f10fd8 objc_exception_rethrow + 4 9 CoreData 0x35624f66 _PFFaultHandlerLookupRow + 1450 10 CoreData 0x356799ba -[NSFaultHandler fulfillFault:withContext:] + 14 11 CoreData 0x35678782 _PF_FulfillDeferredFault + 354 12 CoreData 0x35623f18 _sharedIMPL_pvfk_core + 52 13 CoreData 0x35626b68 _pvfk_5 + 4 14 eLogger 0x0000e346 -[VicLogVC viewWillAppear:] (VicLogVC.m:207) 15 UIKit 0x3636bf14 -[UINavigationController _startTransition:fromViewController:toViewController:] + 604 16 UIKit 0x3636bc3c -[UINavigationController _startDeferredTransitionIfNeeded] + 176 17 UIKit 0x3635dd56 -[UINavigationController pushViewController:transition:forceImmediate:] + 634 18 UIKit 0x3635dacc -[UINavigationController pushViewController:animated:] + 28 19 eLogger 0x00025332 -[TripScreenVC _populateAndDisplayVicLog] (TripScreenVC.m:221) 20 eLogger 0x00025492 -[TripScreenVC _determineLogScreen] (TripScreenVC.m:258) 21 eLogger 0x000255d4 -[TripScreenVC buttonPressed:] (TripScreenVC.m:307) 22 CoreFoundation 0x30d4356a -[NSObject(NSObject) performSelector:withObject:withObject:] + 18 23 UIKit 0x36343ec2 -[UIApplication sendAction:to:from:forEvent:] + 78 24 UIKit 0x36343e62 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 26 25 UIKit 0x36343e34 -[UIControl sendAction:to:forEvent:] + 32 26 UIKit 0x36343b86 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 350 27 UIKit 0x3634441c -[UIControl touchesEnded:withEvent:] + 336 28 UIKit 0x36342bee -[UIWindow _sendTouchesForEvent:] + 362 29 UIKit 0x36342568 -[UIWindow sendEvent:] + 256 30 UIKit 0x3632b30c -[UIApplication sendEvent:] + 292 31 UIKit 0x3632ac4c _UIApplicationHandleEvent + 5084 32 GraphicsServices 0x34e2be70 PurpleEventCallback + 660 33 CoreFoundation 0x30daaa90 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 20 34 CoreFoundation 0x30dac838 __CFRunLoopDoSource1 + 160 35 CoreFoundation 0x30dad606 __CFRunLoopRun + 514 36 CoreFoundation 0x30d3debc CFRunLoopRunSpecific + 224 37 CoreFoundation 0x30d3ddc4 CFRunLoopRunInMode + 52 38 GraphicsServices 0x34e2b418 GSEventRunModal + 108 39 GraphicsServices 0x34e2b4c4 GSEventRun + 56 40 UIKit 0x36355d62 -[UIApplication _run] + 398 41 UIKit 0x36353800 UIApplicationMain + 664 42 eLogger 0x00002ff8 main (main.m:14) 43 eLogger 0x00002fa0 start + 32
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能持有对托管对象的无效引用,看起来它被托管对象上下文变成了错误,可能是在调用上下文上的 -save: 或 -reset 之后。
如果您从存储中删除了一个对象,并且仍然在 ivar 中保留了对托管对象的引用,那么这可能是导致此错误的原因。该对象将被 CoreData 删除,并在调用 -save: 时变成错误(此时您应该 nil 并重置您的 ivars)。但是,当您尝试对对象进行故障处理(通过访问其一个或多个属性)时,将不会在存储中找到该对象,因为您已删除它。
You are likely holding on to an invalid reference to a managed object, it looks like it was turned into a fault by the managed object context, perhaps after calling -save: or -reset on the context.
If you deleted an object from your store, and still held a reference to the managed object in the ivar then that could be the cause of this error. The object will be deleted by CoreData and turned into a fault when -save: is called (at which point you should nil and reset your ivars). But, when you try to fault the object (by accessing one or more of it's properties) it won't be found in the store because you deleted it.