我的代码不断给我一个“不推荐使用 stringwithcontentsofurl”错误,我不知道如何修复它。该应用程序不断将我带到谷歌地图并以 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;
谢谢您的帮助!