iphone - 核心数据导致iPhone 3崩溃

标签 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

最佳答案

您可能会保留对托管对象的无效引用,这似乎是由于托管对象上下文将其变为错误,可能是在上下文上调用了-save:或-reset之后。

如果您从商店中删除了一个对象,但仍在ivar中保留了对托管对象的引用,则可能是导致此错误的原因。当调用-save:时,该对象将被CoreData删除并变成错误(此时应无效并重置ivars)。但是,当您尝试对对象进行故障处理(通过访问其一个或多个属性)时,由于删除了该对象,因此在存储中将找不到该对象。

关于iphone - 核心数据导致iPhone 3崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6325591/

相关文章:

ios - GCD 调度队列是否足以将核心数据上下文限制在单个线程中

visual-studio - librsvg 库在 Release模式下崩溃

Android SQLite INSERT 导致应用程序崩溃

iphone - iOS 应用程序中的屏幕共享?

iphone - 如何将 png 添加到 iPhone 的 UIAlert 按钮

iphone - 如何修复 xcode(和 ios 5)中的链接错误

ios - 无法在 MapView 中显示标记

ios - 每次我向核心数据文件添加内容时,我都会感到满意

ios - 从 CoreData Swift 中的多个实体获取属性

ios - UIApplicationMain 的 EXC_BAD_ACCESS - 如何解释此回溯?