2
我在xcode 6.0.1中創建了一個Core Data模型,然後我開始通過創建一個具有三個提取請求的簡單實體。 我使用了xcode工具。再次可可錯誤134100(用於打開商店的模型與用於創建商店的模型不兼容)
(抱歉,不能張貼圖片)
RequestTask{
String argnames
String argvalues
Integer16 type
String method
}
我做了一些基本的測試:創建,讀取,更新和刪除。一切工作正常,直到我得到那個着名的錯誤信息:
編輯:即使第一次創建商店,這個錯誤發生,所以模型如何使用創建不同於打開它的商店幾行後?
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";
}
我只是用模板代碼鍋核心數據應用與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;
}
這是有趣的部分:我真的在這裏搜索,在谷歌上,在AppleDevelopper ...我敢肯定我失去了一些東西。
- 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我已經嘗試:
- 卸載仿真器上的應用程序+重置模擬器+項目清理並生成
- 手動刪除.sqlite .mom .momd在模擬器上的設備的文件夾
- 創建另一個模型(空)測試,它也不能,所以我已經刪除了關於它的一切
- 嘗試一個真正的iPhone,同樣的問題...
然後在這裏我來了,我很抱歉,如果我錯過了什麼地方已經說,但我想盡問題直接相關和間接相關的有很多......
侮辱都很好,如果你能幫助我。
你爲什麼使用默認?除非您使用該名稱創建配置,否則它將不存在。 – jrturton 2014-10-04 08:37:31
默認配置被命名爲「默認」,我只是認爲,而不是零... – ExekKoffee 2014-10-05 10:20:48