0
votes

I am writing an iphone app using xcode 4.2 and it involves coredata. everything was perfectly fine until I cleaned the project. then I constantly get the following error: Reason = "The model used to open the store is incompatible with the one used to create the store". If I use

NSString *storePath = [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"ChildCare_v02.sqlite"];
NSURL *storeUrl = [NSURL fileURLWithPath:storePath]; 

I get the error above and if I use:

NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"ChildCare_v02.sqlite"];

It retrieves 0 row from my database file,anyone has any idea?

I should mention that the store that I use is not empty and I fill it in with data using another application. (by this I mean I copy the coredata store file from one app to be used in another app.)

Finally, to fix the problem I added some lines of code with in my program to read the records from a sqlite database file and fill the coredata store related to the app. and it worked. I removed the store and ran the sqlite2coredata function once and now my application is working.

2

2 Answers

0
votes

Maybe you changed an attribute or the model in some way so the stores are no longer compatible. Just delete the app on the simulator and on your devices, and the error will go away.

0
votes

This happens when you change the data model, there is one specific file in your derived data that you need to remove in order to generate that model file again, but I can't remember which one is.

The easy thing to do is to remove the app from the device or simulator, clean the build folders and remove the derived data folder, that should do the trick.