xcdatamodeld我必须填写所有属性

时间:2015-02-01 19:42:10

标签: swift core-data ios8

xcdatamodeld我是否必须填写实体中的所有属性?每次我玩核心数据,尝试插入图像路径和字符串,当我插入字符串时崩溃,请帮助,错误如下。

returned error Error Domain=NSCocoaErrorDomain Code=134100 "The operation couldn’t be completed. (Cocoa error 134100.)" UserInfo=0x7fac334193f0 {metadata={
        NSPersistenceFrameworkVersion = 519;
        NSStoreModelVersionHashes =     {
            Entity = <e4d98363 c5118882 22f0534c 6b38c82e 013fbea8 b50048e4 337fa5ba dfebd41e>;
        };
        NSStoreModelVersionHashesVersion = 3;
        NSStoreModelVersionIdentifiers =     (
            ""
        );
        NSStoreType = SQLite;
        NSStoreUUID = "E509F0EC-384B-48BB-954F-81379074917B";
        "_NSAutoVacuumLevel" = 2; }, reason=The model used to open the store is incompatible with the one used to create the store} with userInfo dictionary {
        metadata =     {
            NSPersistenceFrameworkVersion = 519;
            NSStoreModelVersionHashes =         {
                Entity = <e4d98363 c5118882 22f0534c 6b38c82e 013fbea8 b50048e4 337fa5ba dfebd41e>;
            };
            NSStoreModelVersionHashesVersion = 3;
            NSStoreModelVersionIdentifiers =         (
                ""
            );
            NSStoreType = SQLite;
            NSStoreUUID = "E509F0EC-384B-48BB-954F-81379074917B";
            "_NSAutoVacuumLevel" = 2;
        };
        reason = "The model used to open the store is incompatible with the one used to create the store"; } 2015-02-01 22:35:05.476 test[17368:543208] Unresolved error Optional(Error Domain=YOUR_ERROR_DOMAIN Code=9999 "Failed to initialize the application's saved data" UserInfo=0x7fac3419d060 {NSLocalizedFailureReason=There was an error creating or loading the application's saved data., NSLocalizedDescription=Failed to initialize the application's saved data, NSUnderlyingError=0x7fac33419440 "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=0x7fac334193f0 {metadata={
        NSPersistenceFrameworkVersion = 519;
        NSStoreModelVersionHashes =     {
            Entity = <e4d98363 c5118882 22f0534c 6b38c82e 013fbea8 b50048e4 337fa5ba dfebd41e>;
        };
        NSStoreModelVersionHashesVersion = 3;
        NSStoreModelVersionIdentifiers =     (
            ""
        );
        NSStoreType = SQLite;
        NSStoreUUID = "E509F0EC-384B-48BB-954F-81379074917B";
        "_NSAutoVacuumLevel" = 2; }, reason=The model used to open the store is incompatible with the one used to create the store}])

1 个答案:

答案 0 :(得分:1)

您的错误是:用于打开商店的模型与用于创建商店的模型不兼容。 更新核心数据模型时。 (通过添加新属性或新实体等),Core Data必须将旧数据“迁移”到新模型。

但简单的解决方案是删除应用程序(来自模拟器或设备)并在每次修改模型时再次运行它。