0
这是我的情景:迁移核心数据应用到iCloud
我的应用程序使用的核心数据和我加入iCloud的支持,但我有尝试的用户数据迁移到iCloud的问题。
这里是我曾试图:
- 增加了使用addPersistentStoreWithType
NSError* error;
NSURL* oldStoreURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL];
oldStoreURL =[oldStoreURL URLByAppendingPathComponent:@"Database.sqlite"];
// add local store (local version)
NSPersistentStore *store = [self.managedObjectContext.persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil
URL:oldStoreURL
options:options
error:&error];
我目前的本地数据库 - 使用方法migratePersistentStore迁移(可能是我在这里失去了一些东西):
NSURL* storeURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL];
storeURL = [storeURL URLByAppendingPathComponent:@"Database.sqlite"];
[self.managedObjectContext.persistentStoreCoordinator migratePersistentStore:store toURL:storeURL options:iCloudOptions withType:NSSQLiteStoreType error:&error];
我得到一个可可错误134080,无法两次添加相同的商店。
有人可以解释这个migratePersistentStore方法是如何工作的以及我需要为每个参数传递什么?我在苹果文档上发现很少。