我想知道如何更新从 tableView 中选择的 coredata 记录我的代码以保存 coredata 是:
- (IBAction)juardar:(id)sender {
NSUserDefaults *defs=[NSUserDefaults standardUserDefaults];
NSString *sedef_mat=[NSString stringWithFormat:@"%@",[defs objectForKey:@"Materia"]];
//NSLog(@"%@",sedef_mat);
NSManagedObjectContext *context = [self managedObjectContext];
// Create a new managed object
NSManagedObject *newtarea = [NSEntityDescription insertNewObjectForEntityForName:@"Tareas" inManagedObjectContext:context];
[newtarea setValue:self.Nombre.text forKey:@"nombre"];
[newtarea setValue:self.Descripcion.text forKey:@"descripcion"];
[newtarea setValue:sedef_mat forKey:@"materia"];
NSError *error = nil;
// Save the object to persistent store
if (![context save:&error]) {
//NSLog(@"Can't Save! %@ %@", error, [error localizedDescription]);
}
}
谢谢