Created
September 23, 2011 22:29
-
-
Save richardbuckle/1238616 to your computer and use it in GitHub Desktop.
Shut down a Core Data store prior to deleting the underlying file
This file contains 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)closeDown { | |
NSArray *stores = [self.persistentStoreCoordinator persistentStores]; | |
for (NSPersistentStore *store in stores) { | |
DebugLogging(@"Closing Core Data store at %@", [store URL]); | |
NSError *error = nil; | |
if (![self.persistentStoreCoordinator removePersistentStore:store error:&error]) { | |
DebugLogging(@"Unable to close Core Data store: error %@", [error localizedDescription]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Core Data immediately gets v unhappy if you delete the file before closing down properly.