Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 03-19-2010, 01:21 PM   #1 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 18
Default Core Location - Caching Old Location

Hi,

I'm using the core location framework to get the users location. The problem is sometimes the location which first appears is the previously last known location. now I've read a blog and it suggested:

"Core Location will cache data. The first reading it provides to your app is likely to be an old reading, which might or might not be accurate, depending on whether the phone has moved. Make sure to check the timestamp of any location and see if it's from before your app started."

How can I do this? Any ideas?



Regards,

Chris
Cooper_1988 is offline   Reply With Quote
Old 03-20-2010, 07:58 AM   #2 (permalink)
Obj-C Learner
 
Join Date: Apr 2009
Location: Manchester, UK
Posts: 1,030
Send a message via MSN to ZunePod Send a message via Yahoo to ZunePod
Default

Compare the date and times.
__________________
Will code for food
ZunePod is offline   Reply With Quote
Old 03-20-2010, 10:22 AM   #3 (permalink)
Obj-C Learner
 
Join Date: Apr 2009
Location: Manchester, UK
Posts: 1,030
Send a message via MSN to ZunePod Send a message via Yahoo to ZunePod
Default

I know how stupid that post was, but that's basically all you need to do.
__________________
Will code for food
ZunePod is offline   Reply With Quote
Old 03-21-2010, 10:13 AM   #4 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 18
Default

Quote:
Originally Posted by ZunePod View Post
I know how stupid that post was, but that's basically all you need to do.
No it made sense, however, when calling NSdate like so:

self.startDate = [NSDate date];

Is the return date a time stamp? as I'll be comparing to:

newLocation.timestamp;

Thanks.
Cooper_1988 is offline   Reply With Quote
Old 03-21-2010, 12:02 PM   #5 (permalink)
Obj-C Learner
 
Join Date: Apr 2009
Location: Manchester, UK
Posts: 1,030
Send a message via MSN to ZunePod Send a message via Yahoo to ZunePod
Default

Time in Seconds from January 01, 1970 with Objective-C [time] [cocoa] [Objective-C] [unixtime] [NSDate] [NSTimeInterval]

That's basically what you gotta do. (click the link)
__________________
Will code for food
ZunePod is offline   Reply With Quote
Old 03-21-2010, 03:16 PM   #6 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 18
Default

Quote:
Originally Posted by ZunePod View Post
Thanks for the link.. However, I'd already managed to solve the problem by using the following:

if([newLocation.timestamp compare:self.startDate] == NSOrderedDescending )
{

..code..

}

This seems to work, as the startDate is given when the user presses a button and then every time a new location is found, it checks to see whether the timestamp is greater than the startDate, needless to say, if the timestamp provided is an old one i.e before the startDate variable, then nothing will happen and it'll just wait until the next location update.
Cooper_1988 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 254
19 members and 235 guests
ADY, Alsahir, Dani77, Desert Diva, Duncan C, F_Bryant, Grinarn, HemiMG, Herbie, jansan, linkmx, M@realobjects, macquitzon216, prchn4christ, Robiwan, smethorst, spiderguy84, twerner
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,228
Posts: 380,761
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:42 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0