0
내 응용 프로그램의 일부 조건이 충족 될 경우 마지막 행을 숨기려고하지만 내 UITableView에서 마지막 행을 선택하면 내 앱과 충돌이 발생합니다.UITableView의 마지막 행을 숨기려고 시도합니다.
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 11 beyond bounds [0 .. 10]'
이 오류는 의미가 있지만 어떻게 해결할 수 있는지 알 수 없습니다. 내 cellForRowAtIndexPath 방법에
:
NSInteger rowsToDisplay = 0;
if (self.restaurants.count > 0) {
if(indexPath.section == 0)
{
rowsToDisplay = indexPath.row;
if([Restaurant getRestaurantFromRemoteID:[[NSUserDefaults standardUserDefaults] objectForKey:kRestaurantId]].orderSessionActive.boolValue && indexPath.row >= [Restaurant indexPathForRestaurant:[Restaurant getRestaurantFromRemoteID:[[NSUserDefaults standardUserDefaults] objectForKey:kRestaurantId]] inArray:self.restaurants].row)
{
rowsToDisplay = indexPath.row + 1;
}
}
restaurant = self.restaurants[rowsToDisplay];
}
과 numberOfRowsInSection : 방법.
- (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section
{
if (tableView == self.searchBarDisplayContr.searchResultsTableView) {
return [self.searchResults count];
} else {
if ([Restaurant getRestaurantFromRemoteID:[[NSUserDefaults standardUserDefaults] objectForKey:kRestaurantId]].orderSessionActive.boolValue) {
if (section == 0) {
return [self.restaurants count] - 1;
}
}else {
return [self.restaurants count];
}
}
return 0;
}
위 코드는 셀이 tableView의 마지막 셀이 아닌 경우 선택한 셀을 숨 깁니다. 마지막 셀을 선택하면 어떻게 작동합니까?