且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何解析表视图上的api响应?

更新时间:2023-11-24 13:05:16

首先在Dictionary中获取数据,然后使用Keys将所需的内容存储在NSArray ..

First of all get data in Dictionary and then store what you want in NSArray.. using Keys

NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingMutableContainers error: &error];

    NSLog(@"%@",json);

    NSLog(@"%@",delegate.firstArray);

    NSArray * responseArr = json[@"Deviceinfo"];

    NSArray * firstarray=[[NSArray alloc]init];

    for(NSDictionary * dict in responseArr)
    {
        [firstarray addObject:[dict valueForKey:@"name"]];
    }

第一个数组包含名称.. JSON响应中想要的内容.

first array contains names.. what you want from that json response.

,然后将该数据传递到tablview.您要在此处执行的操作将获得名称数据数组.

and then pass that data to tablview. what you want to do here you get the array of name data.