I want to find out photos location using reverseGeocodeLocation. I use the below function
@interface GalleryPhotosViewController ()
{
CLPlacemark *placemark;
}
@end
-(NSString *)getLocation:(CLLocation *)locations{
CLGeocoder *geocoder = [CLGeocoder new];
[geocoder reverseGeocodeLocation:locations completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) {
placemark = [placemarks lastObject];
}];
return placemark.name;
}
I could not get that name when call the function but I get that after execution of other parts of code. I know that reverseGeocodeLocation has a completion block, it is handed off to another thread when execution reaches it. But I need to get that name when call the function. I go through many solutions but could not solve my problem. I want to receive location name in currentLocation.
CLLocation *loc = asset.location;
NSString *currentLocation = [self getLocation:loc];
Where should I change my code. Please help.