yepher / CoreDataUtility

An OSX application that simplifies development and debugging of CoreData enabled applications.
519 stars 49 forks source link

Question about add persistence file to load #26

Closed y0unghe closed 10 years ago

y0unghe commented 10 years ago

I just don't know which file is the persistence file. I run the project in simulator, and in the coredatautility I click the simulator app, choose the right app, but in the step 3, persistence file to load here, I choose the suggested Model.mom file here. and click open, I got "fatal error while opening persistent store". So which file and which file extension I should choose here?

MacMark commented 10 years ago

Open the *.sqlite file in Documents directory of that app.

yepher commented 10 years ago

@izon90,

Yes, it is very likely the "*.sqlite" file in your documents directory as @MacMark says.

Just incase you are still having problems. The persistence file is something you define in your code. To know for sure what the file is called and what the storage type is you can look at your code that will be something like this:

This example is from a desktop app but will be very similar in iOS.

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

_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) {

...

}

In this example you will see the persistence file is called "ThePersistenceFile.sqlite" and the storage format is "NSSQLiteStoreType". Also the *.mom file is the model file that describes your schema.

Maybe I should add a help button to the screen that makes this more clear.