无法在uitableview中解析json文件

时间:2014-10-03 14:11:30

标签: ios json uitableview ios7

嗨朋友们,我正面临着将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视图的类型和分数。

1 个答案:

答案 0 :(得分:1)

调整为:

cell.lblPrice.text=jsonDict[indexPath.row][@"type"];
cell.lblDesc.text= jsonDict[indexPath.row][@"score"];