Core Data ストア (sqlite) をドロップする方法が正しいことを確認したかったのです。クラッシュすることなく機能しているようですが、これが正しい方法であることを確認したかったのです。その後、ユーザーがデータベースに接続すると、新しい sqlite ファイルが自動的に生成されます。
データストアを削除するコードは次のとおりです。
- (BOOL)dropDataStore{
// ----------------------
// This method removes all traces of the Core Data store
// ----------------------
NSError *_error = nil;
NSURL *_storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"Store.sqlite"];
NSPersistentStore *_store = [persistentStoreCoordinator persistentStoreForURL:_storeURL];
// Remove the SQL store and the file associated with it
if ([persistentStoreCoordinator removePersistentStore:_store error:&_error]) {
[[NSFileManager defaultManager] removeItemAtPath:_storeURL.path error:&_error];
}
if (_error) {
return NO;
}
persistentStoreCoordinator = nil;
managedObjectContext = nil;
managedObjectModel = nil;
return YES;
}