当我滚动我的 TableView 时,我得到了 EXC_BAD_ACCESS。我听说像 alloc 这样的东西被称为错误,我不知道。这是我的代码:
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [[resultsDictionary objectForKey: @"bills"] count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// Identifier for retrieving reusable cells.
static NSString *cellIdentifier = @"MyCellIdentifier";
// Attempt to request the reusable cell.
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
// No cell available - create one.
if(cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:cellIdentifier];
}
NSArray *billsArray = [resultsDictionary objectForKey:@"bills"];
cell.textLabel.text = [NSString stringWithFormat:@"%@", [[billsArray objectAtIndex:indexPath.row] objectForKey:@"name"]];
return cell;
}
编辑
我认为错误在这里:
* -[JKArray objectAtIndex:]: 消息发送到释放的实例 0x6a5d030
NSString *cellName = [NSString stringWithFormat:@"%@", [[billsArray objectAtIndex:indexPath.row] objectForKey:@"name"]];