iOs核心数据无法找到源存储第三方类的模型

时间:2014-08-27 11:28:49

标签: ios core-data model database-migration

我尝试通过创建新的模型版本并向此模型添加新属性来尝试迁移核心数据模型。

当我尝试调用addPersistentStoreWithType时,得到此错误:

ERROR EN STORE CREATION: Error Domain=NSCocoaErrorDomain Code=134130 "The operation couldn’t be completed. (Cocoa error 134130.)" UserInfo=0x2092d8e0 {URL=---------, metadata={
    NSPersistenceFrameworkVersion = 419;
    NSStoreModelVersionHashes =     {
        Conversation = <70d77201 17a127ac 55faa8c1 bc5e7827 54bf522d 2de0399c 1be14790 960ffeec>;
        ConversationMessage = <de645809 d140481f 2cf733da d75676a6 4569e6eb 4b5d7d0d 3c0a1841 4e4b2e6c>;
        XMPPCapsCoreDataStorageObject = <fcc8a450 20ad494a 3d9079f2 42eddbf4 6fdda8f1 5ffd78b6 70adb56d e120d7ae>;
        XMPPCapsResourceCoreDataStorageObject = <b4ad78f7 b849a2a8 4193de79 0b80bc86 94e575f4 7e821033 a785a017 c079e928>;
        XMPPGroupCoreDataStorageObject = <2d9d5e0b d7f6f74d 918cb9af f0fe44a4 fae60105 8144ccd0 112d0729 cead71eb>;
        "XMPPMessageArchiving_Contact_CoreDataObject" = <b35921c6 4d8667a9 39c46e41 b04053e9 2b2b2836 db2d9621 b37085a4 4437819f>;
        "XMPPMessageArchiving_Message_CoreDataObject" = <55ad74f0 602bd856 0a324688 c8f8d0e3 af1ba3ff adf512a3 de40f457 037acf23>;
        XMPPResourceCoreDataStorageObject = <e31f4b20 a3c302b6 7b2a74e1 2737e8cb d440ae9a 5bfb503b 32330cdd 17a98978>;
        XMPPRoomMessageCoreDataStorageObject = <e93f6bf3 51ecd04c 083c2478 35c336cb 245370ad 495268d5 e8324e34 af225773>;
        XMPPRoomMessageHybridCoreDataStorageObject = <13824bff 7a0977e0 5f6d47e3 29364758 76864702 329c31e7 02e1d2dc 01ad37de>;
        XMPPRoomOccupantCoreDataStorageObject = <2848335c 9cf626d6 44c5fe10 2c01a746 329d3e3b b785cd89 81949a40 28376f5c>;
        XMPPUserCoreDataStorageObject = <0ef429b0 41998c3a 496ab11a 26bde9ac 7d1a929f 9d7ea102 9ece131d b5a6890c>;
        XMPPvCardAvatarCoreDataStorageObject = <66d4bf5e 05ea2ec1 f355fcd4 32dcdd55 9288a6f0 68d8c045 6c13b9c6 ac300d7a>;
        XMPPvCardCoreDataStorageObject = <adac5b15 e1713a10 bcd16518 eff333ee 4543e45c 13ae60ac ce8bc593 f9b4d1ad>;
        XMPPvCardTempCoreDataStorageObject = <8a708229 823759d9 1ff41f51 3d9913d1 6ae42b49 b0c94c6b 40b41093 51840e6b>;
    };
    NSStoreModelVersionHashesVersion = 3;
    NSStoreModelVersionIdentifiers =     (
        ""
    );
    NSStoreType = SQLite;
    NSStoreUUID = "E3F6E3A8-FCF0-4819-BD4F-9FD14DDA1254";
    "_NSAutoVacuumLevel" = 2; }, reason=Can't find model for source store}

我认为原因是所有以XMPP开头的类都来自第三方库,并且在新的源模型中找不到这些类。

我不知道如何迁移第三方模型,我试图从de数据库中删除这些类,但它们并不存在于同一个数据库中......

修改

我发现出了什么问题,我在managedObjectModel中调用了这个方法:

managedObjectModel = [NSManagedObjectModel mergedModelFromBundles:nil];

但我需要像这样创建de managedObjectModel:

NSString *path = [[NSBundle mainBundle] pathForResource:@"name" ofType:@"momd"];
NSURL *momURL = [NSURL fileURLWithPath:path];
managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:momURL];

问题在于,现在我已经将这些实体混合了...我如何将它们分开?

0 个答案:

没有答案