我的代码总是给我一个“giving code is deprecated”的错误,我不知道如何修复它。这个应用程序一直把我带到谷歌地图,并在0.0纬度,0.0经度显示海洋的中心。这就是我现在拥有的代码。
NSString *locationStr = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlStr]];
NSLog(@"locationstr:%@",locationStr);
NSArray *items = [locationStr componentsSeparatedByString:@","];
double lat = 0.0;
double lon = 0.0;
if([items count] >= 4 && [[items objectAtIndex:0] isEqualToString:@"200"]) {
lat = [[items objectAtIndex:2] doubleValue];
lon = [[items objectAtIndex:3] doubleValue];
} else {
NSLog(@"Address, %@ not found: Error %@",addressStr, [items objectAtIndex:0]);
}
NSLog(@"latlonislatlon:%.12f,%.12f,urlstr:%@",lat,lon,urlStr);
CLLocationCoordinate2D location;
location.latitude = lat;
location.longitude = lon;谢谢你的帮助!
发布于 2013-08-22 13:35:33
它已被替换为
stringWithContentsOfURL:encoding:error: 或
stringWithContentsOfURL:usedEncoding:error:发布于 2013-08-22 13:36:45
因为纬度和经度的变量都被设置为0.0。
发布于 2013-08-22 13:36:49
使用此选项删除弃用警告
NSString *locationStr = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlStr] encoding:NSUTF16BigEndianStringEncoding error:nil];也可以尝试使用不同lat,因为它们可能与lat有问题
https://stackoverflow.com/questions/18372315
复制相似问题