- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
data_web *current_data ;
current_data = [[structured_question data_webs] objectAtIndex:indexPath.row];
NSString *is_submited = [NSString stringWithFormat:@"%@",[current_data content_2]];
if ([is_submited compare:@"Y"] == NSOrderedSame)
cell.accessoryType = UITableViewCellAccessoryCheckmark;
else
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
}
Above is my script. something is wrong in my script and I cannot find a solution.
In the comment you provided the code for your
numberOfRowsInSection
method as follows:However, your
willDisplayCell
ignoresindexPath.section
when you accesscurrent_data
. When the cell from a section that has more rows is displayed, your code will crash.You should change your code to something like this:
I do not know what's
structured_question
in your code was, and why you were using it, but the above should eliminate the crash in theobjectAtIndex:
method.