网络异步请求

// 请求数据
- (void)request:(NSString *)type page:(NSInteger)page {
    
    dispatch_async(_urls_queu, ^{
        [self showLoading];
//        [self.tableView.mj_header beginRefreshing];
        [CommonRequestService queryOrderListOfType:type page:page success:^(id result) {
         
            NSArray *array = (NSArray *)result;
        
            if ([type isEqualToString:DoorServiceType]) {
                
                [self.dataArray addObjectsFromArray:array];
            } else if ([type isEqualToString:GasBluetoothCardType]){
                
                [self.dataGasBlueToothArray addObjectsFromArray:array];
            } else if ([type isEqualToString:GasBluetoothTableType]){
                
                [self.dataGasBlueTableArray addObjectsFromArray:array];
            } else if ([type isEqualToString:GasGeneralCardType]) {
                
                [self.dataGeneralArray addObjectsFromArray:array];
            } else if ([type isEqualToString:WaterCardType]) {
                
                [self.dataWaterArray addObjectsFromArray:array];
            } else if ([type isEqualToString:HeatCardType]) {
                
                [self.dataHeatArray addObjectsFromArray:array];
            } else {
                
                // do nothing...
            }
            
            dispatch_async(dispatch_get_main_queue(), ^{
                [self.tableView reloadData];
                [self.tableView.mj_header endRefreshing];
                [self.tableView.mj_footer endRefreshing];
            });
            [self hideLoading];
        } failure:^(NSString *error) {
            dispatch_async(dispatch_get_main_queue(), ^{
                [self.tableView.mj_header endRefreshing];
                [self.tableView.mj_footer endRefreshing];
            });
            [self hideLoading];
        }];
    });

}

你可能感兴趣的:(ios,数据,网络,异步,ios平台)