I created a Core Data model in xcode 6.0.1, then I began to test the framework possibilities by creating a simple entity with three fetch requests. I used the xcode tool.
(sorry can't post image)
RequestTask{
String argnames
String argvalues
Integer16 type
String method
}
I did some basic tests: create, fetch, update, and delete. Everything was working fine until I got that famous error message:
EDIT : this bug happens even the first time the store is created, so how could the model use to create the store different from the one used to open it a few lines later?
Unresolved error Error Domain=NSCocoaErrorDomain Code=134100 "The operation couldn’t be completed. (Cocoa error 134100.)" UserInfo=0x7a6e0a80 {metadata={
NSPersistenceFrameworkVersion = 519;
NSStoreModelVersionHashes = {
RequestTask = <835609ac 6e164427 c573e9d7 c56ba74e b1cc0283 75a99bb9 0e74286d c95ce429>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
""
);
NSStoreType = SQLite;
NSStoreUUID = "7D5176D6-DBFE-41B3-825C-BEE1F8E74B3E";
"_NSAutoVacuumLevel" = 2;
}, reason=The model used to open the store is incompatible with the one used to create the store}, {
metadata = {
NSPersistenceFrameworkVersion = 519;
NSStoreModelVersionHashes = {
RequestTask = <835609ac 6e164427 c573e9d7 c56ba74e b1cc0283 75a99bb9 0e74286d c95ce429>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
""
);
NSStoreType = SQLite;
NSStoreUUID = "7D5176D6-DBFE-41B3-825C-BEE1F8E74B3E";
"_NSAutoVacuumLevel" = 2;
};
reason = "The model used to open the store is incompatible with the one used to create the store";
}
I just used the template code pot the core data app with some sample on AppleDev.
#pragma mark - Core Data stack
// Returns the managed object context for the application.
// If the context doesn't already exist, it is created and bound to the persistent store coordinator for the application.
- (NSManagedObjectContext *)managedObjectContext
{
if (_managedObjectContext != nil) {
return _managedObjectContext;
}
NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
if (coordinator != nil) {
_managedObjectContext = [[NSManagedObjectContext alloc] init];
[_managedObjectContext setPersistentStoreCoordinator:coordinator];
}
return _managedObjectContext;
}
// Returns the managed object model for the application.
// If the model doesn't already exist, it is created from the application's model.
- (NSManagedObjectModel *)managedObjectModel
{
if (_managedObjectModel != nil) {
return _managedObjectModel;
}
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"AppBesson" withExtension:@"momd"];
//NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"TestModel" withExtension:@"momd"];
_managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
return _managedObjectModel;
}
// Returns the persistent store coordinator for the application.
// If the coordinator doesn't already exist, it is created and the application's store added to it.
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
if (_persistentStoreCoordinator != nil) {
return _persistentStoreCoordinator;
}
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"appbesson.sql"];
//NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"testmodel.sql"];
NSError *error = nil;
_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
NSDictionary *options = @{NSMigratePersistentStoresAutomaticallyOption:@YES, NSInferMappingModelAutomaticallyOption:@YES};
if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:@"Default" URL:storeURL options:nil error:&error]) {
/*
...
*/
[[NSFileManager defaultManager] removeItemAtURL:storeURL error:nil];
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
return _persistentStoreCoordinator;
}
Here is the funny part : I have really searched here, on google, on AppleDevelopper... I'm pretty sure I'm missing something.
- xcode-4-3-unable-to-load-persistent-store-userdictionary-sqlite
- the-model-used-to-open-the-store-is-incompatible-with-the-one-used-to-create-the
- cant-find-model-for-source-store
- cocoa-error-134100-again-model-used-to-open-is-incompatible-from-model-used-t
- incompatible-object-model-version
- how-to-create-the-magic-xcdatamodeld-folder-package/4518137#4518137
SO I already try to :
- uninstall the app on the simulator + reset simulator + project clean and build
- delete manually the .sqlite .mom .momd in the document folder of the simulator's device
- create another model (empty) for test, it also fail so I have deleted everything about it
- tried on a real iPhone, same problem...
Then here I came, I'm sorry if I miss something already said somewhere but I have tried every question directly related and A LOT of indirectly related...
Insults are fine if you help me.