【问题标题】:Copy files 10.10 Yosemite复制文件 10.10 优胜美地
【发布时间】:2015-01-01 15:26:56
【问题描述】:

我有 MAgicalRecords 和 OSX 的项目,它是转换器 SQLITe -> coreData 。 在优胜美地之前 - 它运行良好,但在更新之后 - 有一些麻烦

我的步骤

[MagicalRecord saveWithBlockAndWait:^(NSManagedObjectContext *localContext) {
                      //do some workd with save entity  }];

比我尝试复制转换后得到的数据库

 if ([fileManager fileExistsAtPath:from]) {

    NSFileHandle *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:from];
    [fileHandle seekToEndOfFile];
    [fileHandle closeFile];

    [fileManager copyItemAtPath:from toPath:to error:NULL];
}

BUT 文件在复制之前有一个表格和列,他的大小是 165kb - 在处理 NO 之后 - 他是空的。它是MAC的新功能吗? 正如你所看到的 - 我把 [fileHandle closeFile];但它仍然无法正常工作。

我注意到,如果我在 copyng 文件“from”有 1.8mb 并且包含所有数据之前关闭项目。

还有3个文件

Main.sqlite
Main.sqlite-shm
Main.sqlite-wal

它看起来像“一些内存”中的操作系统白色数据,但不是直接在文件中。 我试图找到解决方案,但没有找到任何解决方案。请帮忙

【问题讨论】:

    标签: macos nsfilemanager magicalrecord osx-yosemite


    【解决方案1】:

    谢谢,SQL 日志模式有问题

    + (NSDictionary *) getOptionsForCreate {
    NSDictionary *pragmaOptions = [NSDictionary dictionaryWithObject:@"MEMORY" forKey:@"journal_mode"];
    
    NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
                             [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
                             [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption,
                             pragmaOptions, NSSQLitePragmasOption, nil];
    return options;
    

    }

      NSPersistentStore *store = [self addPersistentStoreWithType:NSSQLiteStoreType
                                                  configuration:nil
                                                            URL:url
                                                        options:[sel getOptionsForCreate]
                                                          error:&error];
    

    【讨论】:

      【解决方案2】:

      复制这三个文件不会完全复制您的数据库。我建议这个问题的答案:

      Using MagicalRecord to prepopulate a database (swift). -wal journal created, however, data not copied to database

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-06-02
        • 1970-01-01
        • 2014-12-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多