2012-05-20 2 views
0
을 통해 NSMutableDictionary에서 항목 삭제

나는 그렇게 같은 jQuery과 채우는하고 NSMutableDictionary와 .plist 파일을 가지고 사용자가 스 와이프 + 삭제를 할 수있게하고 또한 UiTableView 셀을 사용하여 새 항목을 plist에 "추가"합니다.추가/jQuery과

을 알리는
- (void)tableView:(UITableView *)tableView commitEditingStyle: (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
if (editingStyle == UITableViewCellEditingStyleDelete) { 
    // Delete the row from the data source 
    [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]  withRowAnimation:UITableViewRowAnimationFade]; 
} 
else if (editingStyle == UITableViewCellEditingStyleInsert) { 
    // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view 

내가 시뮬레이터를 실행하고 나에게 오류를 제공 이렇게, "잘못된 갱신 : 섹션 0의 행 개수가 잘못이 내가이 일을 사용하고 코드입니다. 업데이트 (7) 이후에 기존 섹션에 포함 된 행 수는 업데이트 (7) 전에 해당 섹션에 포함 된 행 수와 같거나 그 섹션에서 삽입 또는 삭제 된 행 수를 더하거나 뺀 값이어야합니다 (삽입 된 0 , 1 삭제됨) 및 해당 섹션 안팎으로 이동 된 행 수 (0이 이동되고 0이 이동 됨)를 포함합니다. ' "

누구든지 나를 도와 줄 수 있습니까?

답변

1

테이블에서 행을 제거하지만 데이터 소스에서는 제거하지 않습니다. CourseKeys는 삭제 된 키를 제거하는 mutableArray 여야합니다.

+0

감사합니다. 나는 그것을 수행하는 방법을 알아 내려고 정말로 힘든 시간을 보내고 있습니다. 배열을 nsmutablearray로 바꾸 었는데 이제는 올바르지 않다고 말하는 오류가 발생했습니다. 합계에 대해서도 여전히 동일한 오류가 발생합니다. 어떤 팁? – TerryG

2

courseKeys 배열에서 테이블을 채우고 있습니다. 따라서 대리인 메서드에서

- (void)tableView:(UITableView *)tableView commitEditingStyle: (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    //whether it is an add or edit or delete modify your array from which you are populating the table and reload the table 
}