好的,这是帮助我的解决方案。
- 构建一个档案安装它使用iTunes而不是xcode直接构建。
- 另一个问题是,当xcode可用时,该应用的第一个版本是为第一个iPad构建的,但这些设备尚未售出。这里是老 - 使用(NSPersistentStoreCoordinator *)persistentStoreCoordinator方法:
-(NSPersistentStoreCoordinator *)storeCoorditator{
if(storeCoorditator){
return storeCoorditator;
}
storeCoorditator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self objectModel]];
NSError *lc_error = nil;
NSString *lc_path = [NSString stringWithFormat:@"%@/data.sqlite",[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]];
NSURL *storeUrl = [NSURL fileURLWithPath:lc_path];
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
[storeCoorditator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:options error:&lc_error];
return storeCoorditator;
}
,这里是我试图使用方法:
-(NSPersistentStoreCoordinator *)persistentStoreCoordinator{
if (_persistentStoreCoordinator != nil) {
return _persistentStoreCoordinator;
}
NSURL *storeUrl = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"PDF.sqlite"];
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
NSError *error = nil;
_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:options error:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
return _persistentStoreCoordinator;
}
由于storeUrl是不一样的,数据找不到;) 现在一切正常,我可以把我的数据回来!
似乎更新与存档和iTunes同步工作,而不是直接从xcode工作,但我不知道数据是否已经存在...这是不是真的很实际调试像这样... – Bejil