美文网首页
json解析

json解析

作者: 载你走 | 来源:发表于2018-04-23 09:29 被阅读0次

/ 解析数据

    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

    manager.responseSerializer = [[AFJSONResponseSerializer alloc]init];

    [manager GET:TEST_URL parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {

        dic = (NSDictionary *)responseObject;

        NSLog(@"%@",dic);

        dispatch_async(dispatch_get_main_queue(), ^{

            [self.tv reloadData];

        });

    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {

    }];

}

cell中

    NSString *key = [dic.allKeys objectAtIndex:indexPath.row];

    cell.textLabel.text = key;

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

    ThirdViewController *tVC = [[ThirdViewController alloc]init];

    NSString *key = [dic.allKeys objectAtIndex:indexPath.row];

    tVC.arr = [dic objectForKey:key];

    [self presentViewController:tVC animated:YES completion:^{

    }];

}

cell 中

cell.textLabel.text = [NSString stringWithFormat:@"%@",[_arr[indexPath.row]objectForKey:@"name"]];

    cell.detailTextLabel.text = [NSString stringWithFormat:@"%@",[_arr[indexPath.row]objectForKey:@"like"]];

相关文章

网友评论

      本文标题:json解析

      本文链接:https://www.haomeiwen.com/subject/wxrklftx.html