相关疑难解决方法(0)

iPhone核心数据"自动轻量级迁移"

我正在尝试更新实现核心数据存储的应用程序.我正在为其中一个实体添加一个属性.

我将以下代码添加到我的委托类:

- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {

    if (persistentStoreCoordinator != nil) {
        return persistentStoreCoordinator;
    }

    NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"Shoppee.sqlite"]];

    NSError *error = nil;
    persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];

    NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
                             [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
                             [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];

    if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:options error:&error]) {
        NSLog(@"Error: %@",error);
        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        abort();
    }    

    return persistentStoreCoordinator;
}
Run Code Online (Sandbox Code Playgroud)

这来自以下网址: Doc

执行代码时出现以下错误:

2009-12-01 20:04:22.877

Shoppee [25633:207]错误:错误

Domain = NSCocoaErrorDomain Code = 134130 …

iphone core-data core-data-migration ios

64
推荐指数
5
解决办法
2万
查看次数

标签 统计

core-data ×1

core-data-migration ×1

ios ×1

iphone ×1