내 테이블보기는 핵심 데이터의 데이터가 포함 된 배열로 채워지며 이에 따라 핵심 데이터를 업데이트하면서 행을 삭제하려는 경우 여기에 내 삭제 코드가 있습니다. 핵심 데이터에서 가져온핵심 데이터와 관련된 테이블보기의 행 삭제
*** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-1448.89/UITableView.m:995 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (4) must be equal to the number of rows contained in that section before the update (4), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted).'
내 데이터 소스 arrayList
포함 NSManagedObjects : 나는 삭제 버튼을 쳤을 때
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source.
NSManagedObject *selectedObject = [arrayList objectAtIndex:[indexPath row]];
[managedObjectContext deleteObject:selectedObject];
[arrayList removeObjectAtIndex:[indexPath row]];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
그러나, 나는 다음과 같은 오류를 얻고있다.
아이디어가 있으십니까? 미리 감사드립니다!
업데이트 :
내가 ArrayList에있는 데이터를 제거 할 수 있지만 핵심 데이터의 데이터가 응용 프로그램이 다시 실행하면 목록이 여전히 동일 상응 삭제되지 않은 후 지금은 삭제 작업을 수행 할 수 있습니다.
감사합니다. 이제 삭제할 수 있지만 핵심 데이터의 해당 데이터는 삭제되지 않습니다. 내 코드를 업데이트했습니다. – Michael
나는 내 문제를 해결했다. 나는 컨텍스트를 저장하는 것을 잊어 버렸다. – Michael