使用CLGeocoder解码地址时,遇到错误 Error Domain=kCLErrorDomain Code=2

代码:

#pragma mark 跟踪定位代理方法,每次位置发生变化即会执行(只要定位到相应位置)
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{
CLLocation *location=[locations firstObject];//取出第一个位置
CLLocationCoordinate2D coordinate=location.coordinate;//位置坐标
NSLog(@"经度:%f,纬度:%f,海拔:%f,航向:%f,行走速度:%f",coordinate.longitude,coordinate.latitude,location.altitude,location.course,location.speed); CLGeocoder *gcode = [[CLGeocoder alloc]init];
[gcode reverseGeocodeLocation:location completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) {
if (error) {
NSLog(@"%@",error);
}else
{
CLPlacemark *mk = [placemarks objectAtIndex:0];
NSString *state = [mk.addressDictionary objectForKey:@"State"];
NSString *city = [mk.addressDictionary objectForKey:@"City"];
NSString *lity = [mk.addressDictionary objectForKey:@"SubLocality"];
NSString *stret = [mk.addressDictionary objectForKey:@"Street"];
NSString *name = [mk.addressDictionary objectForKey:@"Name"]; }
isGettingLocation = NO;
}]; //如果不需要实时定位,使用完即使关闭定位服务
[_locationManager stopUpdatingLocation];
}

错误原因:

地址解析需要网络,检查网络连接!手机是否断网了

  

http://stackoverflow.com/questions/29087660/error-domain-kclerrordomain-code-2-the-operation-couldn-t-be-completed-kclerr

CLGeocoder Error Domain=kCLErrorDomain Code=2的更多相关文章

  1. 根据经纬度反向地理编译出地址信息(如果报错:Error Domain=kCLErrorDomain Code=8 "(null)")

    注意:Error Domain=kCLErrorDomain Code=8 "(null)" 如果出现这个错误  一定是 经纬度有问题   一定是 经纬度有问题 一定是 经纬度有问 ...

  2. [ios] 定位报错Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"

    Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error ...

  3. IOS8解决获取位置坐标信息出错(Error Domain=kCLErrorDomain Code=0)(转)

    标题:IOS8解决获取位置坐标信息出错(Error Domain=kCLErrorDomain Code=0) 前几天解决了在ios8上无法使用地址位置服务的问题,最近在模拟器上调试发现获取位置坐标信 ...

  4. IOS8解决获取位置坐标信息出错(Error Domain=kCLErrorDomain Code=0)

    最近在模拟器上调试发现获取位置坐标信息的时候会报错,错误信息: didFailWithError: Error Domain=kCLErrorDomain Code=0 “The operation ...

  5. Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed.

    地图定位 错误:使用CoreLocation获取地理位置信息,报错 Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be ...

  6. didFailWithError: Error Domain=kCLErrorDomain Code=0 “The operation couldn’t be completed. (kCLError

    This error also occurs if you have Scheme/Edit Scheme/Options/Allow Location Simulation checked but ...

  7. iOS json 解析遇到error: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed.

    Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 38 ...

  8. ShareSDK 集成 Google+ 登录 400. Error:redirect_uri_mismatch 和 Error Domain=ShareSDKErrorDomain Code=204

    最近在集成ShareSDK中 Google+ 登录授权时候 出现了如下几个问题 1.    400.  Error:redirect_uri_mismatch 出现这种情况, redirectUri应 ...

  9. Error Domain=ASIHTTPRequestErrorDomain Code=8 "Failed to move file from"xxx/xxx"to"xxx/xxx"

    今天真的好高兴呀 我解决了一个折磨了我一周的问题,真的是激动地要哭出来了,为了这个问题,我嘴也烂了,头发抓了一地啊.虽然解决方法,最后还是展现出了“百度”的伟大,但是我还是很开心,在这里我展示一下我的 ...

随机推荐

  1. 机器人走方格 V3

    1120 . 机器人走方格 V3   基准时间限制:1 秒 空间限制:65536 KB 分值: 160 N * N的方格,从左上到右下画一条线.一个机器人从左上走到右下,只能向右或向下走.并要求只能在 ...

  2. 适配 iOS尺寸

    http://liumh.com/2015/10/21/ios-image-related-matching/ 苹果IPHONE 5主屏尺寸: 4英寸 屏幕尺寸: iPhone 6 Plus 5.5英 ...

  3. Python3基础 print 自带换行功能

    镇场诗:---大梦谁觉,水月中建博客.百千磨难,才知世事无常.---今持佛语,技术无量愿学.愿尽所学,铸一良心博客.------------------------------------------ ...

  4. Python3基础 print 中使用+号,连接两个字符串

    镇场诗:---大梦谁觉,水月中建博客.百千磨难,才知世事无常.---今持佛语,技术无量愿学.愿尽所学,铸一良心博客.------------------------------------------ ...

  5. 一次Linux系统被攻击的分析过程

    IT行业发展到现在,安全问题已经变得至关重要,从最近的“棱镜门”事件中,折射出了很多安全问题,信息安全问题已变得刻不容缓,而做为运维人员,就必须了解一些安全运维准则,同时,要保护自己所负责的业务,首先 ...

  6. uTenux-OS-Task再探

    在第一节中我由于没有拿到开发板,所以被迫无奈,只能将uTenux操作系统移植到手中的一块STM32F103的开发板上,当时对于uTenux的理解还不够,只是看了一下文件架构和效果,虽然移植成功了,但是 ...

  7. BZOJ 3551 Peaks加强版

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=3551 题意:给出一个图,n个点,m条边.边有权值点也有权值.若干询问,(v,x,k),问从 ...

  8. 配置Servlet3.0的方式和注意事项!

  9. C语言文法定义与C程序的推导过程

    program à external_declaration | program external_declaration <程序> ->  <外部声明> |  < ...

  10. zoj 2107&&hdu 1007最近点对问题

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1107 Quoit Design Time Limit: 5 Seconds   ...