2014-11-05 72 views
-1

我有MAgicalRecords和OSX的項目,它是轉換器SQLITe - > coreData。 約塞米蒂之前 - 它的工作很好,但更新後 - 有一些麻煩複製文件10.10優勝美地

我的腳步

[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]; 
} 

後得到卻又文件放在這裏,有一個桌子和柱子在複製之前和他的大小是165kb - 在應付之後否 - 他是空的。它是MAC的新功能嗎?正如你所看到的 - 我把[fileHandle關閉文件];但它仍然無法正常工作。

我注意到,如果我在copyng文件「from」之前關閉了項目1.8mb並且擁有所有數據。

,並有3個文件

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

它看起來像OS白數據「有些記憶」,但不能直接在文件中。 我試圖找到解決方案,但沒有找到任何。請幫忙

回答

0

由於它與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]; 
相關問題