如何在Xcode中显示JSON数组?

时间:2012-09-25 11:38:58

标签: xcode arrays json

我得到了这个json响应,我为nsdictionary创建了一个对象并保存在那里

NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];

下一步我保存为数组

NSArray *country=[json objectForKey:@"results"];

然后我在我的控制台中得到了以下结果。

2012-06-18 09:22:07.647 TableView[468:f803] (
                {
                "Countries" = Iceland;
                 "id"=9046567;
                  "name"=abceeeffdsg;


            },
                {
                "Countries" = Greenland;
                "id"=3524695;
                "name"=gsfjgfsethju;
    },
                {
                 "Countries" = Switzerland;
                 "id"=4613583;
                 "name"=hdfkdgs;
        )

但实际上我想在UITableView中显示这些数据。任何人都可以帮我完成我的工作....感谢你的善意......

1 个答案:

答案 0 :(得分:0)

在tableview数据源方法

1. numberof RowInSection use the [country count];
2. In the cellForRowAtIndexPath

    cell.textLabel.text = [[country objectAtIndex:indexPath.row] objectForKey:@"Countries"];

如果您需要更多详细信息,请与我们联系。