views:

195

answers:

1

I'm after a callback or protocol that will notify me when the user's location is available. So that when a user's location is found I can zoom into where they are. What can I use to do this?

I was thinking there waas something in CoreLocation that could do it, but I can't find how to do it.

[Update]

I've implemented <CLLocationManagerDelegate> with locationManager:didUpdateToLocation:fromLocation: and created an CLLocationManager instance.

locationManager = [[[CLLocationManager alloc] init] autorelease];
locationManager.delegate = self;
[locationManager startUpdatingLocation];

but I'm still not getting any location updates. Also if I use didUpdateLocation: then it will re-zoom to the user each update. Is there a better way than having a check to see if it's the first update?

[Update 2] adding self. to the locationManager got it going and I checked to see if fromLocation: is nil to tell if it was the first update.

+2  A: 

Look into the CLLocationManagerDelegate protocol, specifically -locationManager:didUpdateToLocation:fromLocation:. You can get the accuracy of the location reading from the newLocation parameter's horizontalAccuracy property.

Noah Witherspoon
How do I assign my class as the delegate once the protocol has been implemented?
Affian
Congratulations on 101 answers Noah
Affian