如何在TableviewCell中显示Json数据?

时间:2016-11-07 05:29:38

标签: ios objective-c json uitableview

我从 Webservice

获取此数据
dict : {
    "Apparel & Accessories" = 2;
    "Automotive Services" = 0;
    "Building and Construction" = 1;
    "Business & Professional Services" = 0;
    "Business Services" = 0;
    "Community & Education" = 0;
    Education = 0;
    "Entertainment & Media" = 2;
    FREIGHT = 0;
    "Family & Community" = 0;
    Finance = 0;
    "Finance & Legal" = 1;
    "Food & Dining" = 3;
    "Health & Medicine" = 2;
    "Home & Garden" = 0;
    "Home Repair & Improvement" = 0;
    "Industrial supplies & services" = 0;
    "Information Technology" = 1;
    Legal = 0;
    PELLETS = 0;
    "Personal Care" = 2;
    "Public utilities & environment" = 0;
    "Real Estate" = 0;
    "Real Estate & Insurance" = 0;
    Shopping = 0;
    "Shopping & Specialty Stores" = 0;
    "Sports & Recreation" = 0;
    "TRANSPORT SERVICES" = 0;
    Transportation = 0;
    Travel = 1;
    "Travel & Lodging" = 0;
    Uncategorized = 0;
}

我必须根据下面给出的图像在tableview中显示这些数据

enter image description here

请告诉我该怎么做,我不知道这样做...... 感谢

2 个答案:

答案 0 :(得分:1)

我可以告诉你如何做到这一点 - 只需在数组中添加所需的键。例如:教育,运费然后你可以在表视图中显示数组中的数据。

答案 1 :(得分:1)

NSString *key = [[dict allKeys] objectAtIndex:indexPath.row]
cell.textLabel.text = [NSString stringWithFormat:@"%@ (%@)",key,[dict objectForKey:key]];