基础数据类型

self.tabView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(footrequest)];

pragma mark - 下拉刷新数据

-(void)footrequest{

//  [self.tabView.mj_footer beginRefreshing];
[self.tabView.mj_header beginRefreshing];

AFHTTPSessionManager * manager = [AFHTTPSessionManager manager];

manager.responseSerializer = [AFHTTPResponseSerializer serializer];

[manager GET:@"http://news-at.zhihu.com/api/4/news/before/20190301" parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
    
    NSLog(@"请求成功");
    //将二进制数据转换为字典
    NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
    
    NSArray * arr = [dic objectForKey:@"stories"];
    
    for (NSDictionary * Dic in arr) {
        
        Model * model = [Model mj_objectWithKeyValues:Dic];
        
        [self.dataArray addObject:model];
        
    }
    dispatch_async(dispatch_get_main_queue(), ^{
        [self.tabView reloadData];
    });
    /// 得到加载的数据后 结束下拉加载
    //   [self.tabView.mj_footer endRefreshing];
   // [self.tabView.mj_header endRefreshing];
    
    
} failure:^(NSURLSessionDataTask *task, NSError *error) {
    
    ///结束下拉加载
    // [self.tabView.mj_footer endRefreshing];
    [self.tabView.mj_header endRefreshing];
    NSLog(@"请求失败");
    NSLog(@"%@",error);
    
}];

}

你可能感兴趣的:(基础数据类型)