开发者

NSException in table view core data

开发者 https://www.devze.com 2023-01-31 04:45 出处:网络
Im developing an app that shows basic info from a coredata db, I have the db saving info when hit save button,

Im developing an app that shows basic info from a coredata db, I have the db saving info when hit save button, but when I want to show the data in another view in a table, I get no errors, but an NSexeption>

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:    '+entityForName: could not locate an NSManagedObjectModel for entity name 'Contacts''

the data is saving correctly as I checked it in a sqlite graphic开发者_运维问答al interface, but not showing in the table, with the above error,

how to fix it please?

my little project is in here!

thank you so much!


Okay, your managedObjectContext needs to come from the App Deleagte, in ShowViewController try:

    managedObjectContext = [(CoreDataEnsaAppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];

Right now, the context is coming form _context, which is NULL.

0

精彩评论

暂无评论...
验证码 换一张
取 消