【发布时间】:2017-05-11 06:42:29
【问题描述】:
我使用 Xcode 8.3.2 创建了一个新项目,其核心数据具有与使用 xcode 7 创建的核心数据方法不同的核心数据方法。
它在 iOS 10 上运行,但尝试在 iOS 9 上运行时出错。
新的核心数据方法,如
@synthesize persistentContainer = _persistentContainer;
- (NSPersistentContainer *)persistentContainer {
// The persistent container for the application. This implementation creates and returns a container, having loaded the store for the application to it.
@synchronized (self) {
if (_persistentContainer == nil) {
_persistentContainer = [[NSPersistentContainer alloc] initWithName:@"ieMalayalam"];
[_persistentContainer loadPersistentStoresWithCompletionHandler:^(NSPersistentStoreDescription *storeDescription, NSError *error) {
if (error != nil) {
// Replace this implementation with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog(@"Unresolved error %@, %@", error, error.userInfo);
abort();
}
}];
}
}
return _persistentContainer;
}
- (void)saveContext {
NSManagedObjectContext *context = self.managedObjectContext;
NSError *error = nil;
if ([context hasChanges] && ![context save:&error]) {
// Replace this implementation with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog(@"Unresolved error %@, %@", error, error.userInfo);
abort();
}
}
我们可以替换旧的核心数据方法来支持 ios 9 和 10 吗????? 请帮忙
【问题讨论】:
-
不。你不能那样做。
标签: ios objective-c xcode core-data