Here is how I do a "reset data" function in several apps: (void)reset { // Release CoreData chain _managedObjectContext release; _managedObjectContext = nil; _managedObjectModel release; _managedObjectModel = nil; _persistentStoreCoordinator release; _persistentStoreCoordinator = nil; // Delete the sqlite file NSError *error = nil; if (fileManager fileExistsAtPath:_storeURL. Path) fileManager removeItemAtURL:_storeURL error:&error; // handle error... } Basically I just release the CoreData chain, then delete the persistentStore file. That's what you are trying to do, without using removePersistentStore which I do not care since I will just rebuild the persistentStore coordinator later.
Then at next core data call the chain is rebuilt transparently using singleton-lazy-style constructors like : (NSManagedObjectModel *) managedObjectModel { if (!_managedObjectModel) _managedObjectModel = NSManagedObjectModel mergedModelFromBundles:nil retain; return _managedObjectModel; }.
Here is how I do a "reset data" function in several apps: - (void)reset { // Release CoreData chain _managedObjectContext release; _managedObjectContext = nil; _managedObjectModel release; _managedObjectModel = nil; _persistentStoreCoordinator release; _persistentStoreCoordinator = nil; // Delete the sqlite file NSError *error = nil; if (fileManager fileExistsAtPath:_storeURL. Path) fileManager removeItemAtURL:_storeURL error:&error; // handle error... } Basically I just release the CoreData chain, then delete the persistentStore file. That's what you are trying to do, without using removePersistentStore, which I do not care since I will just rebuild the persistentStore coordinator later.
Then at next core data call the chain is rebuilt transparently using singleton-lazy-style constructors like : - (NSManagedObjectModel *) managedObjectModel { if (!_managedObjectModel) _managedObjectModel = NSManagedObjectModel mergedModelFromBundles:nil retain; return _managedObjectModel; }.
Wow, I think the problem was removePersistentStore. Without that line it worked... I'm curious as to why though. – Johnny Grass Apr 24 at 16:56.
You need to make sure that any managed object context attached to the persistent store have been released before you try to delete the store. Otherwise, the context will evoke that error.
I tried that to no avail (see updated code). – Johnny Grass Apr 24 at 5:48.
You can do it externally given that you only need to do this while developing your application. I have a terminal open in which I remove the store manually before re-running my app. All you need to know is where it is located.
I log it to console everytime my app runs with the following code: CoreDataSingleton sharedManager managedObjectContext; //be sure to create the store first! //Find targeted mom file in the Resources directory NSString *momPath = NSBundle mainBundle pathForResource:@"Parking" ofType:@"mom"; NSLog(@"momd path: %@",momPath); Hope that helps!
A core data persistent store is removed (without quotes):. Remove a core data persistent store.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.