当我为单元格赋值时遇到错误
profileJson = dicData[@"profile"][0];
cell.userName.text = [[profileJson objectForKey:@"First_Name"] objectAtIndex:indexPath.row];
Error: [__NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x7fe5915d7180
如果我写这个声明
cell.userName.text = [profileJson objectForKey:@"First_Name"];
正在分配最后一个值。如果 count
为 3,则输出如下所示:
泰贾
泰贾
泰贾
对于每个单元格。
最佳答案
您似乎不匹配您的代码来询问从 JSON 解压缩的数据结构,您没有包含它,但您似乎需要:
profileJson = dicData[@"profile"][indexPath.row];
cell.userName.text = [profileJson objectForKey:@"First_Name"];
因此,您根据表索引对配置文件数组进行索引,而不是总是采用第一个索引,然后提取第一个名称变量(您之前对数组和字符串感到困惑)。
关于ios - 关于 TableView 单元格indexpath.row,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32762382/