我有這樣的代碼要等待一段時間才能獲得高準確的數據:如何等待,直到位置管理器來獲得高精確的數據
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
if((newLocation.horizontalAccuracy < 150 && newLocation.horizontalAccuracy > 0 /* valid */ && abs(howRecent) < 15.0 /*If it's a relatively recent event less than 15 seconds */))
}
在我的應用程序的其他部分的問題,我需要等待這種方法要回來,所以我用:
[NSThread sleepForTimeInterval:5]; // wait 5 seconds
這是一個很好的做法,或者有更好的方式來等待另一個任務的執行。
你可以指定'desiredAccuracy'到'CLLocationAccuracyBest'或適合你的目的的其他值:http://developer.apple.com/library/ios/DOCUMENTATION/CoreLocation/Reference/CoreLocationConstantsRef/Reference/reference .html#// apple_ref/doc/uid/TP40010237-CH2-SW9 –