coredata using old file version on device

Posted by Martin KS on Stack Overflow See other posts from Stack Overflow or by Martin KS
Published on 2010-04-22T23:07:36Z Indexed on 2010/04/22 23:13 UTC
Read the original article Hit count: 292

This is a follow on from my previous problems here. Resetting the simulator solved all my troubles before, and I've gone on to complete my App.

I now have the exact same problem when installing the app onto my iPhone device. It picks up an old version of my database, which doesn't have the second entity in it, and crashes when I try to access the second entity:

2010-04-22 23:52:18.860 albumCloud[135:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+entityForName: could not locate an NSManagedObjectModel for entity name 'Image''
2010-04-22 23:52:18.874 albumCloud[135:207] Stack: (
  843263261,
  825818644,
  820669213,
  20277,
  844154820, 
  16985,   
  14633,   
  844473760,   
  844851728,   
  862896011,   
  843011267,   
  843009055,   
  860901832,   
  843738160,   
  843731504,   
  11547,   
  11500   
 )

terminate called after throwing an instance of 'NSException'

I have two questions:

1) How on earth do I delete my app thoroughly enough from my phone that it removes the old data? (I've so far tried regular app deletion, deleting and then holding home and power for a reboot, cursing at and threatening the app while running it... everything)

2) How do I prevent this happening when my application is in the App store, and I for some reason decide that I want to add another entity to the store, or another attribute to the existing entities? is there an "if x doesn't exist then create it" method?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about nsmanagedobjectcontext