Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to wait until location is completely found? (Core Location)
    primarykey
    data
    text
    <p>I have a problem within my app. I'm trying to find the user's location to the best preciseness in order to determine their zip-code. Currently I have a button that, when pressed, starts a method named <code>locateMe</code>. </p> <pre><code>-(IBAction)locateMe; { self.locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.desiredAccuracy = kCLLocationAccuracyBest; [locationManager startUpdatingLocation]; </code></pre> <p>Then I've implemented <code>didUpdateToLocation:</code></p> <pre><code>-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation; { NSLog(@"Found location! %f,%f",newLocation.coordinate.latitude,newLocation.coordinate.longitude); } </code></pre> <p>I had previously done much more complicated stuff in <code>didUpdateToLocation</code> but as I tested some things I realized that the first location it found was not precise in the least. So, I put the <code>NSLog</code> call in there and it gave me an output similar to below...</p> <pre><code>Found location! 39.594093,-98.614834 Found location! 39.601372,-98.592171 Found location! 39.601372,-98.592171 Found location! 39.611444,-98.538196 Found location! 39.611444,-98.538196 </code></pre> <p>As you can see, it first gives me a value which is not correct, which was causing problems within my app because it wasn't giving the correct location.</p> <p>So, here's my question. Is there any way I can wait for the location manager to finish finding the most precise location?</p> <p>Thanks in advance!</p> <p><strong>EDIT:</strong> I'm wanting something like this:</p> <pre><code>if (newLocation.horizontalAccuracy &lt;= locationManager.desiredAccuracy) { } </code></pre> <p>But it never gets called!</p>
    singulars
    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