Reputation: 960
i am creating os x app with core data. when i am modify the model. the error occurred that is showed in the image. the reason shown is "The model used to open the store is incompatible with the one used to create the store"; how to fix this error. this same error i fixed by clearing the simulator in iOS app . how to fix this in os x app.
Upvotes: 0
Views: 875
Reputation: 960
Choose Finder and go to Library from Go by clicking option button on keyboard. then search on library using your app Bundle Identifier. delete the folder with it. then Re-launching your application will recreate the folder with no data and you can start re-populating it according to your new model.
Upvotes: -1
Reputation: 1424
As a convenience, on startup I print out the location of the database to the console as follows:
// Get / print location of database for use in testing / debugging
let paths = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.userDomainMask, true)
let path = paths[0] + "/LocalStore.sqlite"
print(path.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines))
Besides being easy to see, I can just select/copy/past this to use in sqliteBrowser.
Upvotes: 0
Reputation: 2563
The usual location for the data store of a non-document-based Core Data application is in ~/Library/Application/Support/com.mydomain.myapp/CocoaAppCD.storedata
.
Rename or delete this file (depending on whether its contents are disposable).
Re-launching your application will recreate the file with no data and you can start re-populating it according to your new model.
With production versions of your application, a model change would require a formal lightweight or heavy migration to preserve the user's data.
Upvotes: 0
Reputation: 31026
If you look at the code that sets up your persistentStoreCoordinator
, it should tell you where the storage for your objects is located and the file name. (The default location from the Apple template is provided by the applicationDocumentsDirectory
method inside the app delegate.)
Upvotes: 0