Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 9th, 2012  |  syntax: None  |  size: 2.02 KB  |  hits: 27  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Program received Signal SIGABRT when scrolling up UITableView
  2. *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 2147483647 beyond bounds [0 .. 48]'
  3.        
  4. - (UITableViewCell *)tableView:(UITableView *)tableView
  5.      cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  6.     static NSString *cellIdentifier = @"CheckedTableViewCell";
  7.  
  8.     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
  9.  
  10.     if (!cell) {
  11.         cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
  12.     }
  13.  
  14.     NSDictionary *rowData = [self.tableData objectAtIndex:[self tableIndexFromIndexPath:indexPath]];//this line may be the source of the crash
  15.     cell.textLabel.text = [rowData objectForKey:kCellTextKey];
  16.  
  17.     if ([[rowData objectForKey:kCellStateKey] boolValue]) {
  18.         UIImageView *imageView1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checked.png"]];
  19.         cell.accessoryView = imageView1;    
  20.     } else {
  21.         UIImageView *imageView2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"unchecked.png"]];
  22.         cell.accessoryView = imageView2;
  23.     }
  24.  
  25.     return cell;
  26.     }
  27.        
  28. - (NSUInteger)tableIndexFromIndexPath:(NSIndexPath *)indexPath {
  29.     // Get list of items at selected section
  30.     NSArray *listData = [tableContents objectForKey:[sortedKeys objectAtIndex:indexPath.section]];
  31.     // Get name of selected row within the section
  32.     NSString *textKey = [listData objectAtIndex:indexPath.row];
  33.     // Look up that name in the tableData array
  34.     for (int i=0; i < [tableData count]; i++) {
  35.         NSDictionary *dict = [tableData objectAtIndex:i];
  36.         if ([[dict objectForKey:kCellTextKey] isEqualToString:textKey]) {
  37.             return i;
  38.         }
  39.     }
  40.     //In case Name was not found
  41.     return NSNotFound;
  42. }
  43.        
  44. NSDictionary *rowData = [self.tableData objectAtIndex:[self tableIndexFromIndexPath:indexPath]];
  45.        
  46. NSDictionary *rowData = [self.tableData objectAtIndex:indexPath.row];