0
사용자 위도와 경도를 가져 와서 콘솔 로그에 올바르게 표시 할 수 있지만 도시 이름이나 기타로 역 지오 코딩을 되돌릴 수 없습니다. 그들과 함께.lat/long-throws 유형 오류를 사용하여 geolocate를 역전시킬 수 없습니다.
내가 뭘 잘못하고 있니?
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
CLLocation *userlatitude = [locations lastObject];
CLLocation *userlongitude = [locations objectAtIndex:locations.count-2];
CLGeocoder *ceo = [[CLGeocoder alloc]init];
CLLocation *loc = [[CLLocation alloc]initWithLatitude:userlatitude longitude:userlongitude];
[ceo reverseGeocodeLocation: loc completionHandler: ^(NSArray *placemarks, NSError *error) {
CLPlacemark *placemark = [placemarks objectAtIndex:0];
NSString *locatedAt = [[placemark.addressDictionary valueForKey:@"FormattedAddressLines"] componentsJoinedByString:@", "];
NSLog(@"Currently located at %@",locatedAt);
}];
[locationManager stopUpdatingLocation];
}
는 또한
CLLocationDegrees userlatitude = [[locations lastObject] doubleValue];
CLLocationDegrees userlongitude = [[locations objectAtIndex:locations.count-2] doubleValue];
와 CLLocation *userlatitude .... objectAtIndex:location.count-2];
를 교체 시도했지만 (이 코드 편집기에서 구문 오류를 표시하지 않는 경우에도)이 런타임시 오류를 반환합니다.