嗨, friend 们,我在将 json 文件解析为 uitableview 时遇到了问题。 我的 json 文件如下所示:
[
{
"id": 1,
"type": "Deal Closed",
"score": 100,
"createdAt": "2014-10-03T08:10:10.000Z",
"updatedAt": "2014-10-03T08:10:10.000Z"
},
{
"id": 2,
"type": "Followers",
"score": 10,
"createdAt": "2014-10-03T08:10:28.000Z",
"updatedAt": "2014-10-03T08:10:28.000Z"
}
]
我的代码在这里..
static NSString *CellIdentifier = @"Leader";
NSString *firstname = [[promoArray objectAtIndex:indexPath.row] objectForKey:@"type"];
NSString *lastname = [[promoArray objectAtIndex:indexPath.row] objectForKey:@"score"];
cell.lblPrice.text=[jsonDict valueForKey:@"type"];
cell.lblDesc.text=[jsonDict valueForKey:@"score"];
它在解析时抛出异常。我需要将类型和分数从 json 文件解析到 Uitable View 。
最佳答案
对此进行调整:
cell.lblPrice.text=jsonDict[indexPath.row][@"type"];
cell.lblDesc.text= jsonDict[indexPath.row][@"score"];
关于ios - 无法在 uitableview 中解析 json 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26180575/