iPhone 开发 - 确保我们有一个新的位置
这个条件如何发挥作用?我无法理解这一点。
if ([newLocation.timestamp timeIntervalSince1970] < [NSDate timeIntervalSinceReferenceDate] - 60) return;
参考:更多 iPhone 3 开发 - 解决 iPhone SDK 3
How does this condition work? I'm unable to comprehend this.
if ([newLocation.timestamp timeIntervalSince1970] < [NSDate timeIntervalSinceReferenceDate] - 60) return;
Reference: More iPhone 3 Development - Tackling iPhone SDK 3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会按照杰森的建议去做。我在本书的论坛上为此写了一篇博客文章,但我从未收到回复!
“假设 newLocation 是 CLLocation 的实例,此条件无法可靠地工作。它使用两个不同的基础,但我假设该检查旨在测试某些位置信息是否小于 60 秒。两者都应该是 timeIntervalSince1970或 timeIntervalSinceReferenceDate (即具有相同的基础)(我们还假设他的意思是 [[NSDate date] dateWithTimeIntervalSinceReferenceDate],因为另一个会抛出异常)。 ——杰森·可可
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