【问题标题】:Core Data causing crash on iPhone 3核心数据导致 iPhone 3 崩溃
【发布时间】:2011-06-13 00:12:14
【问题描述】:

我在核心数据方面遇到了一个奇怪的错误。当我尝试访问核心数据对象时,我的应用有时会崩溃,但并非总是如此。

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

【问题讨论】:

  • 您是否已经尝试清理构建和所有目标?
  • 是的,已经完成了,但是为什么会影响它呢?谢谢你的建议。
  • 我认为如果您对核心数据进行了更改,那么您必须重置模拟器或从模拟器/设备中删除应用程序,以便它可以处理新的更改。

标签: iphone core-data crash


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-09-02
    • 1970-01-01
    • 2011-01-28
    • 2010-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多