【发布时间】:2010-12-27 17:04:18
【问题描述】:
我有从 NSMutableArray 填充的 UITableView。 NSMutableArray 是从我的 NSFetchedResultsController 创建的,它来自另一个视图
Templates *template2 = (Templates *)[fetchedResultsController objectAtIndexPath:indexPath];
qModalView.templateObject = template2;
并被记录到模板对象中,所以我的所有对象都以这种方式保存在我的 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");
}
}
【问题讨论】:
标签: objective-c uitableview core-data nsmutablearray entity-relationship