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

  • Home
  • SEARCH
  • 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 8997095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:50:32+00:00 2026-06-15T23:50:32+00:00

I am trying to return the user’s state using reverseGeocodeLocation. I am using this

  • 0

I am trying to return the user’s state using reverseGeocodeLocation. I am using this code to pull the user’s location from another view.

NSString *userState =[(PDCAppDelegate *)[UIApplication sharedApplication].delegate     
getAddressFromLocation]; 

I am getting the following error: ‘NSInvalidArgumentException’, reason: ‘-[PDCAppDelegate getAddressFromLocation]: unrecognized selector sent to instance. The code I am using in PDCAppDelegate to return the address is below.

-(NSString *)getAddressFromLocation:(CLLocation *)location {
NSString *address;
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError 
*error)
 {
     if(placemarks && placemarks.count > 0)
     {
         CLPlacemark *placemark= [placemarks objectAtIndex:0];

         NSString *address = [NSString stringWithFormat:@"%@ %@,%@ %@", [placemark 
subThoroughfare],[placemark thoroughfare],[placemark locality], [placemark 
administrativeArea]];

         NSLog(@"%@",address);
     }

 }];

return address;
}

Anyone know how to fix this? Thank you!

  • 1 1 Answer
  • 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-15T23:50:33+00:00Added an answer on June 15, 2026 at 11:50 pm

    The CLGeocoder method reverseGeocodeLocation:completionHandler: runs asynchronously. That means you can’t return the address from getAddressFromLocation: because the address is simply not set when you return from this method.

    When the geocoder received the address (or the call caused an error) it will run the completionHandler. You have to set, or show the address from within the completion handler.

    Easiest would be to send a NSNotification, probably not the best way though:

    -(void)getAddressFromLocation:(CLLocation *)location {
        CLGeocoder *geocoder = [[CLGeocoder alloc] init];
        [geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error)
         {
             if (!placemarks) {
                 // handle error
             }
    
             if(placemarks && placemarks.count > 0)
             {
                 CLPlacemark *placemark= [placemarks objectAtIndex:0];
                 NSString *address = [NSString stringWithFormat:@"%@ %@,%@ %@", [placemark subThoroughfare],[placemark thoroughfare],[placemark locality], [placemark administrativeArea]];
    
                 // you have the address.
                 // do something with it.
                 [[NSNotificationCenter defaultCenter] postNotificationName:@"MBDidReceiveAddressNotification" 
                      object:self 
                    userInfo:@{ @"address" : address }];
             }
         }];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having issues trying to return the closest location to the user via
Hey, I am trying to return a user defined class from a web method.
Trying to return all tweets in the last 24hours from a user, but not
I am trying to return a view not issue a redirect to the user
I am trying to return the current username. I get the user name from
I`m trying to return the user location in MKMapKit, but at LOG, it returns
I'm trying to return a user from a MongoDB collection that either matches the
C++: Using and returning character arrays from functions, return type or reference? I'm trying
Im trying to return the value that a $ajax call returns, from a function
I am trying to return the value by using unix_timestamp function but it behaves

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.