Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8391729

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:20:18+00:00 2026-06-09T19:20:18+00:00

I currently have an app that when I place an annotation on a map,

  • 0

I currently have an app that when I place an annotation on a map, it shows the title and subtitle, with the subtitle showing the lat/long/radius information.

 -(NSString *)title{
    return @"Saved position";
}

   - (NSString *)subtitle {
        return [NSString stringWithFormat: @"Lat: %.4F, Lon: %.4F, Rad: %.1fm",
        self.coordinate.latitude, self.coordinate.longitude, self.radius];
    }

    -(id)initWithCoordinate:(CLLocationCoordinate2D) coor{
        self.coordinate=coor;
        NSLog(@"%f,%f",coor.latitude,coor.longitude);
        return self;
    }

I would like to change the subtitle line so that it shows an address. I know this is reverse geocoding using CLGeocoder however, I’m not certain how to do this properly. I’ve looked at many examples online, and have looked at the apple dev site, but its a little overwhelming. Any help is truly appreciated to this novice programmer.

  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T19:20:20+00:00Added an answer on June 9, 2026 at 7:20 pm

    I have solve this and wanted to share how I did it:

    RegionAnnotation.h

    #import <MapKit/MapKit.h>
    #import <CoreFoundation/CoreFoundation.h>
    
    @interface RegionAnnotation : NSObject <MKAnnotation, CLLocationManagerDelegate>
    
    @property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
    @property (nonatomic, readonly, copy) NSString *subtitle;
    @property (nonatomic, readonly, copy) NSString *title;
    
    //Reverse Geocoding
    @property(nonatomic, readonly) CLPlacemark *administrativeArea;//The state
    @property(nonatomic, readonly) CLPlacemark *locality; //The city 
    @property(nonatomic, readonly) CLPlacemark *subThoroughfare;//Street number
    @property(nonatomic, readonly) CLPlacemark *thoroughfare;//Street address
    
    @end
    

    RegionAnnotation.m

    #import "RegionAnnotation.h"
    #import <AddressBookUI/AddressBookUI.h>
    
    @implementation RegionAnnotation
    
    @synthesize coordinate = _coordinate, subtitle = _subtitle, title = _title, administrativeArea = _administrativeArea, location = _location, locality = _locality, subThoroughfare = _subThoroughfare, thoroughfare = _thoroughfare;
    
    - (id)init
    {
        self = [super init];
    
        return self;    
    }
    
    - (void) setCoordinate:(CLLocationCoordinate2D)newCoordinate
    {
        _coordinate = newCoordinate;
    }
    
    - (NSString *)title {
        return @"Monitored Region";
    }
    
    - (void) setSubtitle:(NSString *)newSubtitle
    {
        _subtitle = newSubtitle;
    }
    
    -(void)reverseGeocodeLocation:(CLPlacemark *)placemark
    {
    
        CLGeocoder *geocoder = [[CLGeocoder alloc] init];
    
        CLLocationCoordinate2D coord = self.coordinate;
    
        CLLocation *location = [[CLLocation alloc] initWithLatitude:coord.latitude longitude:coord.longitude];
    
        [geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
            CLPlacemark *placemark = [placemarks objectAtIndex:0];
    
            NSLog(@"%@ %@ %@ %@",
                  placemark.subThoroughfare,
                  placemark.thoroughfare,
                  placemark.locality, 
                  placemark.administrativeArea);
        }];
    }
    
    
    - (NSString *)getAddress {
        CLGeocoder *geocoder = [[CLGeocoder alloc] init];
        CLLocation *location = [[CLLocation alloc] initWithLatitude:self.coordinate.latitude longitude:self.coordinate.longitude];
        NSString *geoAddress = [[NSString alloc] init];
        [geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
            NSLog(@"reverseGeocodeLocation:completionHandler: Completion Handler called!");
            if (error){
                NSLog(@"Geocode failed with error: %@", error);
    //            [self displayError:error];
                return;
            }
            NSLog(@"getAddress Received placemarks: %@", placemarks);
            CLPlacemark *placemark = [placemarks objectAtIndex:0];
             // use the AddressBook framework to create an address dictionary
             NSString *addressString = ABCreateStringWithAddressDictionary(placemark.addressDictionary, NO);        
            _subtitle = addressString;
        }];
    
        return geoAddress;
    
    }
    
    
    @end
    

    I currently have the user do a long push to create an annotation on the map view. Now when the user selects the pin by pressing it, it shows the physical address instead of the longitude and latitude.

    I hope this helps all others who have been searching for a way to do this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have an app that requires connection to a server in multiple activities.
currently I have an app that creates all sorts of different requests to Facebook
I currently have an iPhone app that lets the users take video, upload it
To clarify, I currently have a live app that does not implement in app
We have an app that currently installs itself into 'program files\our app', and it
I have an app that received JSON data from the server. Currently when I
I currently have a deployed app (fortworth.herokuapp.com) that I am attempting to sort movies
I have a web app that currently is inserting x (between 1 + 40)
Hello I have a WinForm app that generates a ton of data. Currently I
I have a version of an app that is currently available in the mexico

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.