from the official RestKit page Restkit Github I found the following to reset the store:
- (void) resetSavedDatabase:(id)sender {
RKManagedObjectStore *objectStore = [[RKObjectManager sharedManager] objectStore];
[objectStore resetPersistentStores];
[objectStore save:nil];
}
That works. But if I then do the following after this method I got a error:
TestEntity *testEntity = [TestEntity createEntity];
testEntity.name = @"TestEntity";
NSError *error;
[[RKObjectManager sharedManager].objectStore save:&error];
Error:
Terminating app due to uncaught exception
‘NSInvalidArgumentException’, reason: ‘Object’s persistent store is
not reachable from this NSManagedObjectContext’s coordinator’
Everything is called in the background. The idea is, that I want to preload some sqlite data and then synchronize them with my synchronize logic. (The logic is working when I do not delete the persistent store)
Can someone help me?
Yes it will automatically recreate the store, but in the following step it will also recreate an object context.
So you almost definitely want to do this on the main thread. Otherwise, RestKit will associate the created persistent store with an object context in the background thread and that will disappear when the thread ends.
I completely don’t understand why you want to do this though.