I have an instance variable lat
(NSString) in my App Delegate. What i want to do is set this variable equal to the user's current latitude in didUpdateToLocation:fromLocation
, such that i can access it from a different view. This is key. So i have this code:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {
appDelegate = (myProjectAppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.lat = [[NSString alloc] initWithFormat:@"%g",newLocation.coordinate.latitude];
}
In terms of debugging, when i do po appDelegate.lat
in the console, when a breakpoint is set here, then i can see the value fine. When i go to my ViewController where i want to use the value, i get out of scope
when i hover over it, and cannot access memory at 0x0
when i try po appDelegate.lat
. This is from the view controller:
[appDelegate.locMan startUpdatingLocation];
NSLog(@"here");
NSLog(appDelegate.lat);
Since nothing is getting printed for my NSLog(appDelegate.lat)
statement, i can only assume something is wrong.
What would be the correct way to debug this.
Thanks.