A short note on CLLocation / CLLocationManager

**** DEPRECATED **** Use http://liip.to/ilocator

Well.. I’ve been testing this Locator quite a while now. Today I had my final attempt, to find out, why I always got either a cached location or an extremely inaccurate location.

Today, I went out with my notebook (yes, there where the sun is..) to debug.

The example of apple says, to check the timestamp of the newLocation. (It should be less than 5..). Yeah well, guess what – it is sometimes 0 in a cached location. And somehow it’s sometimes just a bit over 5 and you’ll have to wait forever to get a new location.


- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation
{
    NSDate* eventDate = newLocation.timestamp;
    NSTimeInterval howRecent = [eventDate timeIntervalSinceNow];

    if (howRecent < -0.0 && howRecent > -10.0) {
        [manager stopUpdatingLocation];

        // USE THE FORCE OF THE LOCATION!
    }
}

This one should work. Maybe that location stuff is working in the U.S. but it wasn’t in Switzerland..

P.S.: I had another issue with a pwned iPhone today. NSXMLParser throw me errors back and I didn’t know why.. I still don’t know why, I guess it had to do with the libxml2 update I did. Workaround? Restore, works fine now.

3 Comments to A short note on CLLocation / CLLocationManager

  1. August 3, 2008 at 9:55 am Permalink

    Damn CMS, just deleted a comment while saving another entry..
    Uhm: pbump: Haven’t noticed that issue yet. The locator on the firmware 2.1 is “said to be” better.. Hopefully, those issues disappear.

    Did you play around with the accuracy and the distancefilter? Helped a bit in my case..

  2. June 13, 2009 at 11:01 am Permalink
    lakshmikanth's Gravatar lakshmikanth

    CLLocationManager is giving me the older location only, if i restart my application then it is giving the correct location.

  3. June 20, 2009 at 2:04 pm Permalink

    beautiful expression of thanks

Dare to comment?