Note that there are some explanatory texts on larger screens.

plurals
  1. POviewDidAppear Method Called before locationManager can Locate User
    primarykey
    data
    text
    <p>I am calling a <code>locationManager</code> in my application <code>delegate</code>, and am referring back to the getUserLatitude and getUserLongitude functions in the <code>viewDidAppear</code> method of various <code>viewControllers</code>. </p> <p>My issue is that my <code>viewDidAppear</code> method launches too quickly for the <code>appDelegate</code> to locate the user, and I get 0.000000 for the <code>latitude</code> and 0.000000 for the <code>longitude</code>. Does anyone know how I might fix this? Thank you!</p> <p><strong>My appDelegate is structured with these location methods:</strong></p> <pre><code>- (NSString *)getUserCoordinates { NSString *userCoordinates = [NSString stringWithFormat:@"latitude: %f longitude: %f", locationManager.location.coordinate.latitude, locationManager.location.coordinate.longitude]; locationManager = [[CLLocationManager alloc] init]; locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; // 100 m [locationManager startUpdatingLocation]; return userCoordinates; } - (NSString *)getUserLatitude { NSString *userLatitude = [NSString stringWithFormat:@"%f", locationManager.location.coordinate.latitude]; return userLatitude; } - (NSString *)getUserLongitude { NSString *userLongitude = [NSString stringWithFormat:@"%f", locationManager.location.coordinate.longitude]; return userLongitude; } </code></pre> <p><strong>I am using this bit of code to get the updated location from the appDelegate:</strong></p> <pre><code>- (void)viewDidAppear:(BOOL)animated { NSString *userLatitude =[(PDCAppDelegate *)[UIApplication sharedApplication].delegate getUserLatitude]; NSString *userLongitude =[(PDCAppDelegate *)[UIApplication sharedApplication].delegate getUserLongitude]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload