У меня есть UITableView, который заполняется из NSMutableArray. NSMutableArray был создан из моего NSFetchedResultsController, который пришел из другого представления.
Templates *template2 = (Templates *)[fetchedResultsController objectAtIndexPath:indexPath];
qModalView.templateObject = template2;
и был записан в templateObject, поэтому у меня есть все мои объекты в этом моем NSMutablArray таким образом.
[templateObject.questions allObjects];
Теперь я хочу удалить строку в представлении таблицы, в массиве и в этом конкретном объекте в templateObject.questions.
Помогите пожалуйста, у меня пока так:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
Questions *question_var = [questionsArray objectAtIndex:indexPath.row];
NSLog(@"_____________________________%@", question_var.question_title);
NSManagedObjectContext *context = [templateObject managedObjectContext];
[context deleteObject:[templateObject.questions objectAtIndexPath:indexPath]];
NSError *error;
if (![context save:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}else{
NSLog(@"deleted");
}
}