我正在尝试用我相信的 NSDictionary 填充动态表格视图的单元格,这是我填充表格视图的方法:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
ResultsCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
NSData *jsonData = self.responseFromServer;
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:jsonData options:kNilOptions error:nil];
NSArray *results = [json objectForKey:@"myData"];
for (NSDictionary *item in results) {
cell.title.text =[[item objectForKey:@"title"]objectAtIndex:indexPath.row];
}
// Configure the cell...
return cell;
}
如果我有
cell.title.text =[item objectForKey:@"title"];
几乎可以工作,但我所有的头衔都是一样的。但是目前我得到的错误是:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x7612940'
我不确定这意味着什么或如何解决它。