开发者

iPhone Development - Making sure we have a fresh location

开发者 https://www.devze.com 2022-12-26 13:20 出处:网络
How does this condition work? I\'m unable to comprehend this. if ([newLocation.timestamp timeIntervalSince1970] < [NSDate timeIntervalSinceReferenceDate] - 60) return;

How does this condition work? I'm unable to comprehend this.

if ([newLocation.timestamp timeIntervalSince1970] < [NSDate timeIntervalSinceReferenceDate] - 60) return;

Reference: More iPhone 3 Dev开发者_如何学编程elopment - Tackling iPhone SDK 3


I'll go with what Jason suggested. I wrote a blog post for this on the book's forum but i never heard back!

"This condition doesn't work reliably, assuming that newLocation is an instance of CLLocation. It's using two different bases, but I would assume the check is meant to test whether some location information is less than 60 seconds old. Both should be either timeIntervalSince1970 or timeIntervalSinceReferenceDate (i.e., have the same basis). (Also we assume he meant [[NSDate date] dateWithTimeIntervalSinceReferenceDate] since the other would throw an exception)." – Jason Coco

0

精彩评论

暂无评论...
验证码 换一张
取 消