我正在尝试更新实现核心数据存储的应用程序。我正在向其中一个实体添加一个属性。
我将以下代码添加到我的委托类中:
- (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;
}
这来自以下 URL: Doc
执行代码时出现以下错误:
2009-12-01 20:04:22.877
Shoppee[25633:207] 错误:错误
域=NSCocoaErrorDomain 代码=134130
UserInfo = 0x1624d20“操作无法完成。(可可错误134130。)”2009-12-01 20:04:22.879 Shoppee [25633:207]未解决的错误错误域= NSCocoaErrorDomain代码= 134130 UserInfo = 0x1624d20“操作无法完成已完成。(Cocoa 错误 134130。)",{ URL = file://localhost/Users/Eric/Library/Application%20Support/iPhone%20Simulator/User/Applications/A8A8FB73-9AB9-4EB7-8F83-82F5B4467AF1/Documents/MyApp .sqlite; 元数据 = { NSPersistenceFrameworkVersion = 241; NSStoreModelVersionHashes = { 项目 = <869d4b20 088e5c44 5c345006 87d245cd 67ab9bc4 14cadf45 180251e9 f741a98f>; 存储 = <47c250f4 895e6fd1 5033ab42 22d2d493 7819ba75 3c0acffc 2dc54515 8deeed7a>;}; NSStoreModelVersionHashesVersion = 3; NSStoreModelVersionIdentifiers = ( ); NSStoreType = SQLite;NSStoreUUID = "8DC65301-3BC5-42BE-80B8-E44577B8F8E1"; }; reason = "找不到源存储的模型"; }
看起来我需要以某种方式包含原始数据模型,但我不知道该怎么做。有什么建议么?