【发布时间】:2014-07-05 11:47:36
【问题描述】:
我只是在学习有关 CoreData 的教程,但遇到了问题。 首先 myApp 崩溃了,因为我没有正确命名数据库(如教程中所示),通过调试器发现了这一点。 但是现在我的程序可以正常执行,但是会抛出以下错误:
Error Domain=NSCocoaErrorDomain Code=134100 "The operation couldn’t be completed
即在以下方法中:
if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) {
/*
Replace this implementation with code to handle the error appropriately.
abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
Typical reasons for an error here include:
* The persistent store is not accessible;
* The schema for the persistent store is incompatible with current managed object model.
Check the error message to determine what the actual problem was.
If the persistent store is not accessible, there is typically something wrong with the file path. Often, a file URL is pointing into the application's resources directory instead of a writeable directory.
If you encounter schema incompatibility errors during development, you can reduce their frequency by:
* Simply deleting the existing store:
[[NSFileManager defaultManager] removeItemAtURL:storeURL error:nil]
* Performing automatic lightweight migration by passing the following dictionary as the options parameter:
@{NSMigratePersistentStoresAutomaticallyOption:@YES, NSInferMappingModelAutomaticallyOption:@YES}
Lightweight migration will only work for a limited set of schema changes; consult "Core Data Model Versioning and Data Migration Programming Guide" for details.
*/
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
但我不知道出了什么问题。据我了解,错误是,我用来创建条目的函数与检索它们的函数不同,对吗? 如果是这样,我该如何解决?你们还需要什么其他信息来帮助我解决这个问题?
我已经为这个问题烦恼了好几个小时了:-/
哦,顺便说一句,这里是控制台(或调试窗口)输出:
2014-05-16 16:47:57.380 TimeStamp[884:60b] User clicked Save
2014-05-16 16:47:57.399 TimeStamp[884:60b] Unresolved error Error Domain=NSCocoaErrorDomain Code=134100 "The operation couldn’t be completed. (Cocoa error 134100.)" UserInfo=0xd166b20 {metadata={
NSPersistenceFrameworkVersion = 479;
NSStoreModelVersionHashes = {
Entity = <a8bc66e2 f3ce9700 9c39bc5d 3ea64ca6 69e06023 3cc0f8e1 2768a9d5 5a520a0d>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
""
);
NSStoreType = SQLite;
NSStoreUUID = "588B9127-5774-45B3-8BF0-2C5CD0F07321";
"_NSAutoVacuumLevel" = 2;}, reason=The model used to open the store is incompatible with the one used to create the store}, {
metadata = {
NSPersistenceFrameworkVersion = 479;
NSStoreModelVersionHashes = {
Entity = <a8bc66e2 f3ce9700 9c39bc5d 3ea64ca6 69e06023 3cc0f8e1 2768a9d5 5a520a0d>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
""
);
NSStoreType = SQLite;
NSStoreUUID = "588B9127-5774-45B3-8BF0-2C5CD0F07321";
"_NSAutoVacuumLevel" = 2;
};
reason = "The model used to open the store is incompatible with the one used to create the store";}
(lldb)
谢谢大家!
【问题讨论】: