2014-10-04 85 views
0

我有一个应用程序设置核心数据和一个名为“主题”的实体,当我尝试添加另一个实体的核心数据称为“家庭作业”,我的应用程序崩溃,我得到这个错误快速崩溃与两个核心数据实体

2014-10-04 12:41:05.302 HomeJournal[1050:20160] Unresolved error Optional(Error Domain=YOUR_ERROR_DOMAIN Code=9999 "Failed to initialize the application's saved data" UserInfo=0x7fe6bb60cac0 {NSLocalizedFailureReason=There was an error creating or loading the application's saved data., NSLocalizedDescription=Failed to initialize the application's saved data, NSUnderlyingError=0x7fe6bb524760 "The operation couldn’t be completed. (Cocoa error 134100.)"}), Optional([NSLocalizedFailureReason: There was an error creating or loading the application's saved data., NSLocalizedDescription: Failed to initialize the application's saved data, NSUnderlyingError: Error Domain=NSCocoaErrorDomain Code=134100 "The operation couldn’t be completed. (Cocoa error 134100.)" UserInfo=0x7fe6bb524720 {metadata={ 
    NSPersistenceFrameworkVersion = 519; 
    NSStoreModelVersionHashes =  { 
     Subject = <e90676da 933291ac ffe738ee ec80ba71 d2cc14a0 df80b9fe b69b358c 43d4cebc>; 
    }; 

    NSStoreModelVersionHashesVersion = 3; 
    NSStoreModelVersionIdentifiers =  (
     "" 
    ); 
    NSStoreType = SQLite; 
    NSStoreUUID = "CB1FC120-99D2-4DB2-9C08-D6679CC6ECB7"; 
    "_NSAutoVacuumLevel" = 2; 
}, reason=The model used to open the store is incompatible with the one used to create the store}]) 
(lldb) 

我不知道我做错了什么,我把它设置为获取数据了使用此代码

var appDel:AppDelegate = (UIApplication.sharedApplication().delegate as AppDelegate) 
     var context:NSManagedObjectContext = appDel.managedObjectContext! 
     var request = NSFetchRequest(entityName: "Subject") 
     request.returnsObjectsAsFaults = false; 

这完美的作品称为“主体”的实体,如果有只有一个实体。 先进的感谢

+2

删除设备上的应用程序,然后重建您的项目。它应该解决你的问题。 – 2014-10-04 12:08:47

+0

@POB谢谢完美 – 2014-10-04 12:11:49

+0

可能的重复[核心数据保存模型不工作的iOS](http://stackoverflow.com/questions/20388365/core-data-save-model-not-working-ios) – 2014-10-04 12:23:36

回答

0

正如有人建议在评论中,尝试从模拟器中删除应用程序,然后重新安装。如果它仍然失败,则将您为数据模型创建的NSManagedObject文件与实际数据模型中的NSManagedObject文件进行匹配。您可能会创建文件,然后更改模型。