json解析

/ 解析数据

    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解析)