haiii 我有 json 数据,比如
{
NetworkMembers = (
{
id = 1;
memberId = 1;
networkId = 1;
position = 0;
type = H;
},
最后我像这样放入数组:
for (int i=0; i<[array count]; i++) {
NSDictionary *dictionary = [array objectAtIndex:i];
NSArray *array2=[dictionary valueForKey:@"NetworkMembers"];
for (int j=0; j<[array2 count]; j++) {
NSDictionary *dictionary2 = [array2 objectAtIndex:j];
NSLog(@"J value %@",[dictionary2 valueForKey:@"type"]);
[self.tablArray addObject:[dictionary2valueForKey:@"type"]];
[self.tablArray addObject:[dictionary2 valueForKey:@"id"]];
}
}
最后我得到像tableArray(H,1,H,2,H,3,H,4,H,6然后在索引路径的行的单元格中我写了类似的代码
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"testing"];
if(!cell)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"testing"];
}
cell.textLabel.text = [tablArray objectAtIndex:indexPath.row];
if([tablArray count]>0)
{
cell.detailTextLabel.text=[[tablArray objectAtIndex:indexPath.row]stringValue];
}
return cell;
但是由于未捕获的异常“NSInvalidArgumentException”,打印详细文本标签 iam 出现类似 Terminating app 的错误,原因:“-[__NSCFString stringValue]: unrecognized selector sent to instance 0x109314510 ”