{"success":true,"code":"2001","message":"查询成功","data":[{"userListByPreWeekHitTimes":[{"UserId":207677921948,"NickName":"站点管理员","Avatar":"http://192.168.1.103:8066/Uploads/Avatars/avatar_default.jpg","BigAvatar":"http://192.168.1.103:8066/Uploads/Avatars/avatar_default_big.jpg","Gender":0,"NowAreaCode":"","IsFollowed":false,"FollowerCount":0,"FollowedCount":0}],"userListByOnline":[],"userListByInterested":null}]}
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
// 原本需要拼接get访问URL ? & =
// NSDictionary *dict = @{@"format": @"json"};
// 网络访问是异步的,回调是主线程的,因此程序员不用管在主线程更新UI的事情
[manager GET:@"http://192.168.1.103:8066/MobileClient_2/UserSpace/UserList.aspx" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"%@", responseObject);
// 提问:NSURLConnection异步方法回调,是在子线程
// 得到回调之后,通常更新UI,是在主线程
NSLog(@"%@", [NSThread currentThread]);
NSMutableArray* dic1=[responseObject objectForKey:@"data"];
NSMutableDictionary* dic2=[dic1 objectAtIndex:0];
NSMutableArray* dic3=[dic2 objectForKey:@"userListByPreWeekHitTimes"];
NSMutableDictionary* dic4=[dic3 objectAtIndex:0];
NSString* str=[dic4 objectForKey:@"NickName"];
//解析json到各个字符串
NSLog(@".......%@",str);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"%@", error);
}];
【】代表数组 用array {}代表dic 用dictionary做。。。。不熟悉容器啊