- (void)loadData {
// 结束与其相对的上拉数据刷新操作
[self.tableView.footer endRefreshing];
// 发送请求
NSMutableDictionary *params = [NSMutableDictionary dictionary];
params[@"a"] = @"list";
params[@"c"] = @"data";
params[@"type"] = @(self.type);
_params = params;
[[AFHTTPSessionManager manager] GET:@"http://api.budejie.com/api/api_open.php" parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
if (_params != params) {
return;
}
[responseObject writeToFile:@"/Users/liyang/Desktop/liyangtiezi.plist" atomically:YES
];
// 字典 -> 模型
_topics = [LYTopic objectArrayWithKeyValuesArray:responseObject[@"list"]];
_maxtime = responseObject[@"info"][@"maxtime"];
// 刷新表格
[self.tableView reloadData];
// 结束刷新
[self.tableView.header endRefreshing];
// 下拉刷新成功再清空页码为零
page = 0;
} failure:^(NSURLSessionDataTask *task, NSError *error) {
if (_params != params) {
return;
}
// 结束刷新
[self.tableView.header endRefreshing];
}];
}
网友评论