我不明白這個文檔中的例子: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