(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showDetail"]) {
NSError *error=nil;
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
NSManagedObject *selectedObject = [[self fetchedResultsController] objectAtIndexPath:indexPath];
NSLog(@"Segue");
[[segue destinationViewController] setDetailItem:selectedObject];
objet = selectedObject;
[self showQuizz:selectedObject];
int num=1;
[selectedObject setValue:[NSNumber numberWithInt:num] forKey:@"fldId"];
if ([self.managedObjectContext save:&error]){
NSLog(@"fldId Not Saved");
NSLog(@"Handle the error");
NSLog(@"Unresolved Error %@, %@",error, [error userInfo]);
}
}
非常感谢任何帮助
答案 0 :(得分:0)
你应该添加一个!,你应该检查保存的结果是否为NO,而不是YES:
if (![self.managedObjectContext save:&error]){
NSLog(@"fldId Not Saved");
NSLog(@"Handle the error");
NSLog(@"Unresolved Error %@, %@",error, [error userInfo]);
}
换句话说,保存的调用是成功的。您可以看到此here的更多示例。