使用MJExtension框架将字典转换为模型
DJHomeViewController.m
/** 载入新的微博数据 */ - (void)loadNewStatues { AFHTTPSessionManager *requestManager = [AFHTTPSessionManager manager]; // 获取当前登录用户及其所关注(授权)用户的最新微博 NSString *urlString = @"https://api.weibo.com/2/statuses/friends_timeline.json"; NSMutableDictionary *params = [NSMutableDictionary dictionary]; params[@"access_token"] = [DJAccountTool account].access_token; [requestManager GET:urlString parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, NSDictionary * _Nullable responseObject) { // 保存当前微博数据 self.statuses = [DJStatus mj_objectArrayWithKeyValuesArray:responseObject[@"statuses"]]; // 刷新tableView [self.tableView reloadData]; } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { DJLog(@"获取当前登录用户微博失败"); }]; }
最终效果: