2
NSMutableArray에서 채워지는 UITableView가 있습니다. NSMutableArray를 다른보기UITableView에서 행 삭제 NSMutableArray 및 ManagedObjectContext
Templates *template2 = (Templates *)[fetchedResultsController objectAtIndexPath:indexPath];
qModalView.templateObject = template2;
에서 와서 templateObject에 기록 된 내 NSFetchedResultsController에서 만들어진, 그래서 난 내 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");
}
}
및 데이터베이스에서 어떻게 삭제합니까? 자동으로 진행됩니까? –
"[context deleteObject : [templateObject.questions objectAtIndexPath : indexPath]]; "및 "[context save : & error]"줄에 이미 데이터베이스가 삭제되었습니다. –