2

I don't undestand... i succeed in populate my table view but when i scroll it crash without message..

i create my tabQuestion with a NSMutablearray and then add this in my delegate : cellForRowAtIndexPath

NSDictionary    *question = [self.tabQuestion objectAtIndex:indexPath.row];

[cell setAccessoryType: UITableViewCellAccessoryDisclosureIndicator];

cell.textLabel.text = [NSString stringWithFormat:@"%@", [question objectForKey:@"question"]];
cell.detailTextLabel.text =  [NSString stringWithFormat:@"%@", [question objectForKey:@"reponse"]];

if ([[question objectForKey:@"bOk"] isEqualToString:@"1"]) {
        cell.imageView.image = [UIImage imageNamed:@"ok.png"];
}
else
{
        cell.imageView.image = [UIImage imageNamed:@"ok.png"];   
}

[question release];



return cell;
Nekto
  • 17,837
  • 1
  • 55
  • 65
Sylvain Bessot
  • 181
  • 1
  • 3
  • 13

1 Answers1

2

You shouldn't release objects that were returned by method objectAtIndex: of NSArray. It happens very rare.

Try to remove first of all line: [question release];

Then check if your self.tabQuestion contains needful amount of objects.

Nekto
  • 17,837
  • 1
  • 55
  • 65
  • if i only add these lines i have the crash -> NSLog(@"%@ %i",[tabQuestion description],indexPath.row); NSLog(@"%@",[[self.tabQuestion objectAtIndex:indexPath.row] description]); index (15) beyond bounds (0) – Sylvain Bessot Sep 21 '11 at 16:19
  • i find the solution. in fact, the system autorelease my object. i solve it with a retain. – Sylvain Bessot Sep 22 '11 at 03:17