2014-11-06 2 views
0

내가 jQuery과NSInternalInconsistencyException jQuery과

-(void) closePickerViewRow:(id) sender { 

    if(self.pickerIsShown && [self.forecastsData count] > 0){ 

     [self.tableView beginUpdates]; 
     NSMutableArray* tempArray = [self.forecastsData mutableCopy]; 
     NSIndexPath* indexPath = [NSIndexPath indexPathForRow:1 inSection:0]; 
     [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; 
     [tempArray removeObjectAtIndex:1]; 
     self.forecastsData = [tempArray copy]; 
     [self.tableView endUpdates]; 

    } 
} 

에서 행을 삭제하기 위해 노력하고있어하지만 오류

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 (11) 
must be equal to the number of rows contained in that section before the 
update(11),plus or minus the number of rows inserted or deleted from that 
section (0 inserted, 1 deleted) and plus or minus the number of rows moved into 
or out of that section (0 moved in, 0 moved out).' 

내가 갱신 데이터 소스 self.forecastData 해요, 그리고 후 10 개 요소가에게 있습니다 행을 삭제합니다 (시작시 11). 따라서 요소의 수는 옳습니다. 문제는 어디에있을 수 있습니까?

+2

를 * 첫번째 * . –

답변

1

데이터 삭제 있는 tableview 이야기하기 전에 : 나는 그것이 차이를 만드는 모르겠지만, 내가 사용한 적이 때마다`deleteRowsAtIndexPaths`, 내 데이터 세트에서 객체를 제거

[tempArray removeObjectAtIndex:1]; 
self.forecastsData = [tempArray copy]; 
[self.tableView deleteRowsAtIndexPaths:@[indexPath] 
         withRowAnimation:UITableViewRowAnimationFade]; 
+0

그래, 문제가 됐어, 고마워! – Valeriy