You can add a storage file to the application (sqlite db in most cases). Then in your delegate deletion edit persistentStoreCoordinator getter merhod:
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator { if (persistentStoreCoordinator_ != nil) { return persistentStoreCoordinator_; } NSString *storePath = [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"CoreDataStore.sqlite"]; // Check if the store exists in. if (![[NSFileManager defaultManager] fileExistsAtPath:storePath]) { // copy the payload to the store location. NSString *bundleStore = [[NSBundle mainBundle] pathForResource:@"YourPayload" ofType:@"sqlite"]; NSError *error = nil; [[NSFileManager defaultManager] copyItemAtPath:bundleStore toPath:storePath error:&error]; if (error){ NSLog(@"Error copying payload: %@", error); } } NSError *error = nil; NSURL *storeURL = [NSURL fileURLWithPath:storePath]; persistentStoreCoordinator_ = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; if (![persistentStoreCoordinator_ addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } return persistentStoreCoordinator_; }
rckoenes
source share