I keep on getting "save operation failure" after any change on my Xcode Data Model I keep on getting "save operation failure" after any change on my Xcode Data Model xcode xcode

I keep on getting "save operation failure" after any change on my Xcode Data Model


Do you have NSMigratePersistentStoresAutomaticallyOption and NSInferMappingModelAutomaticallyOption options set when you create your persistentStoreCoordinator in the App Delegate?

- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {    if (persistentStoreCoordinator != nil) {        return persistentStoreCoordinator;    }    NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"database.sqlite"]];    NSError *error = nil;    NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:                             [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,                             [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];    persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [self managedObjectModel]];    if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:options error:&error]) {        // Handle error    }        return persistentStoreCoordinator;}


If you are only getting this error in the Simulator then you have changed your data model and it hasn't deleted the sqlite file that you were previously using.

So go to: ~/Library/Application Support/iPhone Simulator/User/Applications/

Then look through the HEX-named folders until you see your app. Open the Documents directory and delete the sqlite file. The error should go away.


if you are running this on the simulator/iphone, also uninstall the app too. worked for me on the simulator only after i deleted the app!