我有一个 MutableArray 填充了数据库中的值:
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)'
为什么会出现这个错误?