I have an MutableArray filled with values from a database:
NSMutableArray *objectsArray = [[NSMutableArray alloc] init];
for (int n=0; n<[self.array count]; n++) {
[objectsArray addObject:[[self.array objectAtIndex:n] objectForKey:@"Name"]];
[objectsArray addObject:[[self.array objectAtIndex:n] objectForKey:@"Name_En"]];
}
cell.textLabel.text = [[[dic objectForKey:@"d"] objectAtIndex:indexPath.row] objectForKey:@"Name"];
cell.detailTextLabel.text = [[[dic objectForKey:@"d"] objectAtIndex:indexPath.row] objectForKey:@"Name_En"];
Terminating app due to uncaught exception 'NSRangeException', reason: '-[__NSCFArray objectAtIndex:]: index (5) beyond bounds (5)'
You are probably saying the table that you have 6 rows, but you actually have 5. The reason for this exception is that the table view asks for cell for indexPath.row
with value of 5, which means it thinks that there are 6 [0:5] rows, but your array in the dictionary has 5 items [0:5).