核心数据导致iPhone 3崩溃

时间:2011-06-13 00:12:14

标签: iphone core-data crash

我的核心数据出现了奇怪的错误。有时候,但是当我尝试访问核心数据对象时,我的应用程序崩溃的时间并非总是如此。

它经常出现在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

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

1 个答案:

答案 0 :(得分:1)

您可能持有对托管对象的无效引用,看起来它被托管对象上下文变成了错误,可能是在上下文中调用-save:或-reset之后。

如果您从商店中删除了一个对象,并且仍然在ivar中保留了对托管对象的引用,那么这可能是导致此错误的原因。 CoreData会删除该对象,并在调用-save:时变为错误(此时您应该nil并重置您的ivars)。但是,当您尝试对对象进行故障时(通过访问其中一个或多个属性),在商店中找不到它,因为您删除了它。