以前,当您进行轻量级迁移时,核心数据会在相同的文件夹中创建一个备份文件,如~yourFile。但是使用Lion我找不到这个备份文件。文件被藏在什么地方了吗?我确实看了文档,但没有成功。任何帮助都将不胜感激。
非常感谢
马里奥
发布于 2012-02-10 09:56:06
似乎˜文件不再是自动创建的。因此,我找到的解决方案是以编程方式创建该文件。所以,我在这里发布我的解决方案
// Determine if a migration is needed
NSDictionary *sourceMetadata = [NSPersistentStoreCoordinator metadataForPersistentStoreOfType:NSSQLiteStoreType URL:url error:&error];
NSManagedObjectModel *destinationModel = [persistentStoreCoordinator managedObjectModel];
BOOL pscCompatibile = [destinationModel isConfiguration:nil compatibleWithStoreMetadata:sourceMetadata];
// if migration is needed, copy the file appending OLD to the original name
if (pscCompatibile == 0) {
NSLog(@"doing migration");
NSURL *urlOld = [NSURL fileURLWithPath: [applicationSupportDirectory stringByAppendingPathComponent: @"AudioStManDataOLD"]];
[[NSFileManager defaultManager] copyItemAtURL:url toURL:urlOld error:&error];
}tx马里奥
https://stackoverflow.com/questions/9137971
复制相似问题