我想知道如果你可以经常调用NSManagedObjectContext保存。我保存的代码是标准的UIApplicationDelegate代码:调用NSManagedObjectContext上的saveContext太多
- (void)saveContext
{
NSError *error = nil;
NSManagedObjectContext *managedObjectContext = self.managedObjectContext;
if (managedObjectContext != nil) {
if ([managedObjectContext hasChanges] && ![managedObjectContext 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();
}
}
}
我带来了一个模式,以创建一个新的报警类型对象的应用程序。模态有几个屏幕,像重复的日子。类似于Apple重复的日子观点,我推出了一个新的viewController,它显示了重复的日子。当我回到用户输入闹钟名称的模式主屏幕时,是否可以调用saveContext?我想我想知道是否需要担心为较小的屏幕调用saveContext,如重复的日子,然后用户在主模态屏幕上点击完成,然后立即再次调用saveContext。