我不明白这个文档中的例子:timeIntervalSinceNow
方法应该显示一个正值,但是我们怎么能达到代码中提到的“5”? (我认为它是0或多或少,或-10,-20,-30等...但我们怎样才能得到一个正值,如5):您的帮助用负值(CLLocation示例)计算'timeIntervalSinceNow'?
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
// test the age of the location measurement to determine if the measurement is cached
// in most cases you will not want to rely on cached measurements
NSTimeInterval locationAge = -[newLocation.timestamp timeIntervalSinceNow];
if (locationAge > 5.0) return;
谢谢
感谢IuliusCæsar,你将如何强制cllocation总是发送新的位置而不是缓存的位置? (不只是让应用程序不做任何事情,以防止值被缓存,但告诉应用程序:“如果你有一个缓存值,重新启动cllocation”?) – Paul 2012-04-03 16:22:04
你不能;它会尽快给你一个新的。所有你可以做它等待它。 – 2012-04-03 16:24:54
谢谢,我无法找到默认缓存的时间量?你知道关于它的一些事吗? – Paul 2012-04-04 04:42:25