【问题标题】:Swift crashing with two core data entitiesSwift 与两个核心数据实体崩溃
【发布时间】:2015-03-24 22:51:22
【问题描述】:

我有一个应用程序设置了核心数据和一个名为“主题”的实体,当我尝试将另一个实体添加到名为“家庭作业”的核心数据时,我的应用程序崩溃并出现此错误

    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;

如果只有一个实体,这非常有效。 提前感谢

【问题讨论】:

  • 删除您设备上的应用程序,然后重建您的项目。它应该可以解决您的问题。
  • @POB 谢谢完美工作
  • @POB 它的答案相同,但与保存模型的问题不同,但这个问题是关于多个实体的

标签: core-data swift entity


【解决方案1】:

正如评论中建议的那样,尝试从模拟器中删除该应用并重新安装。如果仍然失败,则将您为数据模型创建的 NSManagedObject 文件与实际数据模型中的文件匹配。可能是您创建了文件然后更改了模型。

【讨论】:

    猜你喜欢
    • 2016-08-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-09
    相关资源
    最近更新 更多