【问题标题】:coredata intermittant crash [NSEntityDescription entityForName:inManagedObjectContext:]coredata 间歇性崩溃 [NSEntityDescription entityForName:inManagedObjectContext:]
【发布时间】:2012-12-31 07:53:02
【问题描述】:

我有一位客户使用的 iPad 2 发生了崩溃,我无法重现它。

崩溃报告:

Last Exception Backtrace:
0   CoreFoundation                  0x37a5429e __exceptionPreprocess
1   libobjc.A.dylib                 0x32b3b97a objc_exception_throw
2   CoreData                        0x317438d8 +[NSEntityDescription entityForName:inManagedObjectContext:]
3   MyApp                           0x000fc916 -[DetailViewController fetchedResultsController] (DetailViewController.m:237)
4   MyApp                           0x000fc374 -[DetailViewController addToMySermons] (DetailViewController.m:170)
5   MyApp                           0x000fc080 -[DetailViewController actionSheet:didDismissWithButtonIndex:] (DetailViewController.m:140)
6   UIKit                           0x35db60cc -[UIActionSheet(Private) _popoutAnimationDidStop:finished:]
7   UIKit                           0x35a73aae -[UIViewAnimationState sendDelegateAnimationDidStop:finished:]
8   UIKit                           0x35ae88ca -[UIViewAnimationState animationDidStop:finished:]
9   QuartzCore                      0x30a91bd4 CA::Layer::run_animation_callbacks(void*)
10  libdispatch.dylib               0x358924b2 _dispatch_client_callout
11  libdispatch.dylib               0x358971b8 _dispatch_main_queue_callback_4CF$VARIANT$mp
12  CoreFoundation                  0x37a27f36 __CFRunLoopRun
13  CoreFoundation                  0x3799aeb8 CFRunLoopRunSpecific
14  CoreFoundation                  0x3799ad44 CFRunLoopRunInMode
15  GraphicsServices                0x3989a2e6 GSEventRunModal
16  UIKit                           0x35ab22f4 UIApplicationMain
17  MyApp                           0x000f595a main (main.m:16)
18  MyApp                           0x000f5910 start + 36

我可以看到它发生在 +[NSEntityDescription entityForName:inManagedObjectContext:] 调用中,如下所示:

NSEntityDescription *entity = [NSEntityDescription entityForName:@"StoredPage" inManagedObjectContext:self.managedObjectContext];

self.managedObjectContext 是从 UISplitViewController 左侧的 UITableViewController 传入的。

这对我和成千上万使用该应用程序的人来说都很好,只是这个人有问题。我们让他删除应用程序并重新安装并重新启动他的 iPad,但没有帮助。

有没有办法让我捕获实际抛出的异常并将其显示在 UIAlertView 中,以便我可以看到实际发生的情况,还是我必须获取他的 UDID 并给他一个调试版本?

【问题讨论】:

    标签: ios xcode ipad core-data crash


    【解决方案1】:

    对我来说,问题是 ManagedObjectContext 没有持久存储协调器。

    为了发现抛出异常的详细信息,我做了以下操作

    NSEntityDescription *entity = nil; @try { // do something entity = [NSEntityDescription entityForName:@"MyEntity" inManagedObjectContext:managedObjectContext]; } @catch (NSException *exception) { // error happened! do something about the error state NSLog(@"exception creating entity for managedobject content MyEntity = %@", exception); return nil; } @finally { // do something to keep the program still running properly }

    其中记录了以下内容:

    ```

    为 managedobject 内容创建实体的异常 MyEntity = +entityForName: nil 不是用于搜索实体名称“MyEntity”的合法 NSPersistentStoreCoordinator

    ```

    我很欣赏这是一个老问题,但我怀疑它并不少见。

    【讨论】:

      【解决方案2】:

      您的核心数据模型是否发生了变化?

      当 Core Data 模型文件与创建数据库文件时使用的文件不匹配时,我看到了一些难以重现和奇​​怪的崩溃。

      最好通过始终创建核心数据模型(模式)的新“版本”来避免这种情况。

      【讨论】:

        猜你喜欢
        • 2013-06-14
        • 2015-11-22
        • 1970-01-01
        • 1970-01-01
        • 2015-05-21
        • 2014-09-15
        • 1970-01-01
        • 2021-03-31
        相关资源
        最近更新 更多