这是我在tableView:cellForRowAtIndexPath:方法中的代码,

static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}

// Configure the cell...
NSDictionary *temp = [self.placeArray objectAtIndex:[indexPath row]];
cell.textLabel.text = [temp objectForKey:@"name"];
cell.detailTextLabel.text = [[temp objectForKey:@"distance"] stringByAppendingString:@" km from Banglore"];
cell.imageView.image =[UIImage imageNamed:[temp objectForKey:@"category"]];
return cell;


我有例外

Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 3 beyond bounds [0 .. 2]'


有指针吗?

最佳答案

检查您的Tableview代表是否像

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return self.placeArray.count;
}


否则让我知道...

关于ios - UITableView中的NSRangeException,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19652990/

10-10 17:35
查看更多