Created
October 30, 2012 18:32
-
-
Save distractdiverge/3982098 to your computer and use it in GitHub Desktop.
Clear Persistent Store
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void) resetPersistentStore | |
{ | |
NSURL* storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"Model.sqlite"]; | |
NSPersistentStore* store = [_persistentStoreCoordinator persistentStoreForURL:storeURL]; | |
NSError* error = nil; | |
[_persistentStoreCoordinator removePersistentStore:store error:&error]; | |
if (error) { | |
NSLog(@"An error occured resetting the persistent store: %@",error.localizedDescription); | |
return; | |
} | |
error = nil; | |
[[NSFileManager defaultManager] removeItemAtURL:storeURL error:&error]; | |
if (error) { | |
NSLog(@"An error occured removing the persistent store file: %@",error.localizedDescription); | |
return; | |
} | |
} | |
-(void) resetManagedObjectContext | |
{ | |
_managedObjectContext = nil; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment