首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Lion上的Core Data Lightweight Migration不保存备份文件吗?

Lion上的Core Data Lightweight Migration不保存备份文件吗?
EN

Stack Overflow用户
提问于 2012-02-04 10:41:52
回答 1查看 158关注 0票数 0

以前,当您进行轻量级迁移时,核心数据会在相同的文件夹中创建一个备份文件,如~yourFile。但是使用Lion我找不到这个备份文件。文件被藏在什么地方了吗?我确实看了文档,但没有成功。任何帮助都将不胜感激。

非常感谢

马里奥

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-02-10 09:56:06

似乎˜文件不再是自动创建的。因此,我找到的解决方案是以编程方式创建该文件。所以,我在这里发布我的解决方案

代码语言:javascript
复制
// 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马里奥

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9137971

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档