关于表视图单元格indexpath.row

时间:2015-09-24 13:16:37

标签: ios objective-c uitableview

当我为像

这样的单元格赋值时,我收到错误
cell.userName.text = [profileJson objectForKey:@"First_Name"];
  

错误:   [__NSCFString objectAtIndex:]:无法识别的选择器发送到实例0x7fe5915d7180

如果我写这个陈述

count

最后一个值正在分配。如果JOIN为3,则输出如下所示:

的Teja

的Teja

的Teja

对于每个细胞。

2 个答案:

答案 0 :(得分:2)

您似乎不匹配您的代码来查询从JSON解压缩的数据结构,但您还没有包含它,但看起来您需要:

profileJson = dicData[@"profile"][indexPath.row];

cell.userName.text = [profileJson objectForKey:@"First_Name"];

所以你根据你的表索引索引到profiles数组,而不是总是取第一个,然后提取第一个名称变量(你之前对数组和字符串感到困惑)。

答案 1 :(得分:0)

这在你的" cellForRowAtIndexPath中:"方法

NSDictionary *profileJson = dicData[@"profile"][indexPath.row];

NSString *userNameString = [profileJson objectForKey:@"First_Name"];

cell.userName.text = userNameString;