ios tableView加载cell时有延时的操作 比如反地理编码

获取到数据之后 
#pragma mark -- 获取狗狗设备信息列表
- (void) getDogoptionalInfo {
    UserManager *manger = [UserManager getUserManager];
    if ([manger checkIsLogined] == NO){
         [self.dogEpumentInfoArr removeAllObjects];
        return;
    }
    if (_logOutState == YES) {
       [self.dogEpumentInfoArr removeAllObjects];
        [self.tableView reloadData];
        return;
    }
    dispatch_async(dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        //获取狗狗列表
        HttpRequest *request = [[HttpRequest alloc] init];
        NSString *url = [HOMEDOGINFO_URL stringByAppendingString:[manger getToken]];
        [request setStrUrl:url];
        [request setCompletionBlockWithType:HttpTypeGet success:^(HttpResponse *response) {
            dispatch_async(dispatch_get_main_queue(), ^{
                NSArray *arr = response.responseData;
                if ([arr isKindOfClass:[NSArray class]]) {
                    [self.dogEpumentInfoArr removeAllObjects];
                    for (int i=0; i<arr.count; i++) {
                        NSDictionary *dic = arr[i];
                        
                        HomeDogInfoModel *info = [[HomeDogInfoModel alloc] initWithDictionary:dic error:nil];
                         if ((info.device != nil)||(info.device.length > 5)){
                             [self getlocationDetailName:info andIndex:i];
                            [self.dogEpumentInfoArr addObject:info];
                         }
                    }
                }
                _netState = YES;
                [self.tableView reloadData];
            });
        } failure:^(HttpResponse *response) {
            if (self.dogEpumentInfoArr.count == 0) {
                if (response.stateCode == 0) {
                    _netState = NO;
                    [self.tableView reloadData];
                }
            }
        }];
    });
    
}

#pragma mark -- 根据经纬度获取当前地理位置
- (void) getlocationDetailName:(HomeDogInfoModel *)model andIndex:(NSInteger)index {
    //
    dispatch_async(dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        CLGeocoder *geocoder = [[CLGeocoder alloc] init];
        CLLocation *location=[[CLLocation alloc]initWithLatitude:model.latitude longitude:model.longitude];
        [geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
            if (error||placemarks.count==0) {
            }else//编码成功
            {
                for (CLPlacemark *placeMark in placemarks)
                {
                    
                    NSDictionary *addressDic=placeMark.addressDictionary;
                    model.location = [[addressDic objectForKey:@"Name"] stringByAppendingString:@"附近"];
                     [self refishTablecell:index + 1];
                    
                }
            }
        }];
    });
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值