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 8234559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:31:18+00:00 2026-06-07T18:31:18+00:00

FINAL SOLUTION THAT I USED: This method did not work out very well for

  • 0

FINAL SOLUTION THAT I USED: This method did not work out very well for me, and I only had 2 variables which had to be transferred so I decided to use NSNotificationCenter to send the objects. Please use this ONLY if you have very little objects to transfer, or else it could get extremely messy! If you want to learn more about this, I recommend that you check out this question: pass NSString variable to other class with NSNotification Good Luck!

I’m trying to access data from my App Delegate, but I’m always getting a (null).

EDIT: If anyone wants the full code, here it is: http://pastebin.com/hNUPMcvB

Here’s the code in my AppDelegate:

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
    // Stop Location Services
    [locationManager stopUpdatingLocation];
    // Some Reverse Geocoding...
    CLGeocoder * geoCoder = [[CLGeocoder alloc] init];
    [geoCoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray *placemarks, NSError *error) {
        for (CLPlacemark * placemark in placemarks) {
            City = [[placemark locality] stringByReplacingOccurrencesOfString:@" " withString:@"+"];
            State = [[placemark administrativeArea] stringByReplacingOccurrencesOfString:@" " withString:@"+"];
            Final = [NSString stringWithFormat:@"%@,%@", City, State];
            currentLocation = [NSString stringWithFormat:@"%@", Final];
            [self everythingelse];
            NSLog(@"AAA%@", currentLocation);
        }
    }
     ];

}

This is how I’m accessing the code from my other View Controller:

    ForecasterAppDelegate *BossMan = (ForecasterAppDelegate *)[[UIApplication sharedApplication] delegate];
    CurrentLocation = BossMan.currentLocation;
    NSLog(@"CCC%@", CurrentLocation);

It always logs as CCC(null). In my AppDelegate, it comes out right, but in the other view controller its not. I’m either making a small mistake or a huge one, any help would be great!

EDIT: Here are my header files:

My App Delegate .h:

@interface ForecasterAppDelegate : UIResponder <UIApplicationDelegate, CLLocationManagerDelegate> {
    UIStoryboard *storyboard;
    NSString *City, *State, *Final, *currentLocation;
    NSMutableString *FinalQuery;
    CLLocationManager *locationManager;
    CLPlacemark * myPlacemark;
}

@property (strong, nonatomic) UIWindow *window;
@property (nonatomic,retain) CLLocationManager *locationManager;
@property (nonatomic, retain) NSMutableString *FinalQuery;
@property (strong, nonatomic) NSString *currentLocation;
@property (nonatomic, retain) NSString *Final;

and here is my View Controller .h file:

@interface View1 : UIViewController <CLLocationManagerDelegate, LocationDamn> {
        CLLocationManager *locationManager;
        CLPlacemark * myPlacemark;
        NSString *launchpath;
        NSString *City, *State, *condition, *Final, *degreesign, *changeLocation, *currentLocations;
    }


    @property (nonatomic,retain) CLLocationManager *locationManager;
    @property (nonatomic,retain) IBOutlet UILabel *currentTempLabel, *highTempLabel, *lowTempLabel, *conditionsLabel, *cityLabel, *day2c, *day3c, *currentconditions;
    @property (nonatomic,retain) IBOutlet NSString *currentLocations;



    @end

In my viewdidload of my ViewController, I have this:

    [self performSelector:@selector(DoSomethingCool) withObject:nil afterDelay:1.5];

so that the location manager has some time to get the location.

  • 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-07T18:31:20+00:00Added an answer on June 7, 2026 at 6:31 pm

    You’re not using the setter when assigning your value therefore it’s not retaining the value. Try changing:

    currentLocation = [NSString stringWithFormat:@"%@", Final];
    

    To

    self.currentLocation = [NSString stringWithFormat:@"%@", Final];
    

    To avoid confusion you can stop declaring your instance variables in your headers… try this:

    @interface ForecasterAppDelegate : UIResponder <UIApplicationDelegate, CLLocationManagerDelegate> 
    
    @property (strong, nonatomic) UIWindow *window;
    @property (nonatomic,retain) CLLocationManager *locationManager;
    @property (nonatomic, retain) NSMutableString *FinalQuery;
    @property (strong, nonatomic) NSString *currentLocation;
    @property (nonatomic, retain) NSString *Final;
    

    and add this to your implementation

    @sysnthesize window=_window, locationManager=_locationManager, FinalQuery = _FinalQuery, currentLocation=_currentLocation, Final=_final;
    

    That’s the standard way and then if you try

     currentLocation = [NSString stringWithFormat:@"%@", Final];
    

    The compiler will throw an error, which will prevent you from setting the instance variable by accident. Now, with those changes, your real issue starts to become apparent. Your code was setting the value like

    _currentLocation = [NSString stringWithFormat:@"%@",Final];
    

    This sets the instance variable directly so the value does not get retained. The value is probably getting thrown away at the next curly bracket because nothing has retained it. When you prefix it with self as self.currentLocation = some value then you are passing the value to a setter which retains. Then it should be available for all your view controllers 🙂

    Hope this helps, if you find it confusing let me know and I’ll try to edit it down a little.

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

Sidebar

Related Questions

Update: I've added an answer that describes my final solution (hint: the single Expr
Can final keyword be used for a method?
I have an APEX class that is used to send an email out each
Update (21st Sept 2016) - Thanks to Digbyswift for commenting that this solution still
This is about my solution to that question It is been a long time
I've already started similar topic , but still didn't find final solution... So here
FINAL EDIT: After following the answer from Darin Dimitrov, I have found that the
fairly new Android developer here. I've come across a strange problem that I'm not
After long investigations and reading this question I still didn't get a good solution
was wondering if you could help me out: I have a method called initializeAll

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.