I'm getting the following error:
Code:
This NSPersistentStoreCoordinator has no persistent stores. It cannot perform a save operation.
I am trying to reset the database during run time. i"ve used the following function:
Code:
-(void)resetDatabase{
if (persistentStoreCoordinator_ != nil) {
NSError *error;
NSArray *stores = [persistentStoreCoordinator_ persistentStores];
for (NSPersistentStore *store in stores){
[persistentStoreCoordinator_ removePersistentStore:store error:&error];
[[NSFileManager defaultManager] removeItemAtPath:store.URL.path error:&error];
//@TODO: Capture the error
}
}
}
I know I deleted the persistent store, however, I figured when you try to insert data into the database, it will recreate the store b/c its currently nil.
Any suggestions / ideas?
Thanks