Reputation: 71
I have one customer using an iPad 2 that's experiencing a crash and I can't reproduce it.
Crash report:
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
I can see that it's happening at the +[NSEntityDescription entityForName:inManagedObjectContext:] call which looks like this:
NSEntityDescription *entity = [NSEntityDescription entityForName:@"StoredPage" inManagedObjectContext:self.managedObjectContext];
The self.managedObjectContext is passed in from UITableViewController on the left side of a UISplitViewController.
This works fine for me and the thousands of others using the app, it's only this one person thats having the problem. We've had him delete the app and reinstall it and reboot his iPad but it didn't help.
Is there a way for me to catch the actual exception thrown and display it in a UIAlertView so I can see what's actually happening or am I going to have to get his UDID and give him a debug version?
Upvotes: 2
Views: 891
Reputation: 1788
For me the issue was that the ManagedObjectContext did not have a persistent store coordinator.
To discover the details of the exception thrown I did the following
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
}
Which logged the following:
```
exception creating entity for managedobject content MyEntity = +entityForName: nil is not a legal NSPersistentStoreCoordinator for searching for entity name 'MyEntity'
```
I appreciate this is an old question, but I suspect it's not that uncommon an issue.
Upvotes: 2
Reputation: 9857
Has your core data model changed?
I have seen some hard to reproduce and odd crashes occur when the Core Data model file doesn't match the one that was used at the time the database file was created.
This situation is best avoided by always creating a new "version" of your core data model (schema).
Upvotes: 0