swift:无法将核心数据添加到现有项目中 - 尝试了一切

时间:2015-01-28 13:24:52

标签: ios swift core-data

我已尝试过与我类似的问题中提供的所有建议和解决方案,但我仍然无法将新核心数据添加到现有项目中。我试过的事情:

  1. 将新核心数据文件添加到简单的应用程序项目
  2. 从有效的旧项目中复制核心数据文件
  3. 创建了一个空白的新项目,选择了Core Data,然后添加了我的所有文件。
  4. 多次修改/更新/交叉检查AppDelegate。
  5. 但是我注意到了一件事:

    当我将核心数据文件从旧项目复制到当前时,它会给出错误fatal error: unexpectedly found nil while unwrapping an Optional value

    然而,当我创建一个新的核心数据文件时,会出现biggg错误,如下所示

    CoreData: error: -addPersistentStoreWithType:SQLite configuration:(null) URL:file:///Users/raunekk/Library/Developer/CoreSimulator/Devices/9CDAADD4-E413-4955-AF1B-9FBBB2B8E691/data/Containers/Data/Application/4FF507C8-9F5B-4982-B3B7-AAAF1F377FC0/Documents/MarineInsight.sqlite options:(null) ... returned error Error Domain=NSCocoaErrorDomain Code=134100 "The operation couldn’t be completed. (Cocoa error 134100.)" UserInfo=0x7fc90b63eaf0 {metadata={
    NSPersistenceFrameworkVersion = 519;
    NSStoreModelVersionHashes =     {
    };
    NSStoreModelVersionHashesVersion = 3;
    NSStoreModelVersionIdentifiers =     (
        ""
    );
    NSStoreType = SQLite;
    NSStoreUUID = "C8B3DC24-E463-4328-8459-56124E1E5B4D";
    "_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 =         {
        };
        NSStoreModelVersionHashesVersion = 3;
        NSStoreModelVersionIdentifiers =         (
            ""
        );
        NSStoreType = SQLite;
        NSStoreUUID = "C8B3DC24-E463-4328-8459-56124E1E5B4D";
        "_NSAutoVacuumLevel" = 2;
         };
    reason = "The model used to open the store is incompatible with 
    the one used to create the store";
      }
    2015-01-28 18:50:32.951 MarineInsight[8820:2204891] Unresolved 
     error      Optional(Error Domain=YOUR_ERROR_DOMAIN Code=9999 "Failed 
     to    initialize the application's saved data" UserInfo=0x7fc90b420cd0 {NSLocalizedFailureReason=There was an error creating or loading the application's saved data., NSLocalizedDescription=Failed to initialize the application's saved data, NSUnderlyingError=0x7fc90b63f510 "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=0x7fc90b63eaf0 {metadata={
    NSPersistenceFrameworkVersion = 519;
    NSStoreModelVersionHashes =     {
    };
    NSStoreModelVersionHashesVersion = 3;
    NSStoreModelVersionIdentifiers =     (
        ""
    );
    NSStoreType = SQLite;
    NSStoreUUID = "C8B3DC24-E463-4328-8459-56124E1E5B4D";
    "_NSAutoVacuumLevel" = 2;
       }, reason=The model used to open the store is incompatible with 
     the one    used  to create the store}])
    

    我在行let modelURL

    的此函数中获取AppDelegate中的可选值错误
    lazy var managedObjectModel: NSManagedObjectModel = {
        // The managed object model for the application. This property is not optional. It is a fatal error for the application not to be able to find and load its model.
        let modelURL = NSBundle.mainBundle().URLForResource("Blog", withExtension: "momd")!
        return NSManagedObjectModel(contentsOfURL: modelURL)
        }()
    

    我在我的智慧结束..plsssss plsss帮助我

0 个答案:

没有答案