我正在使用CoreLocation來獲取用戶位置。我需要抓住用戶的位置然後發送到服務器。我有這一切工作,但!我正在實施locationManager:(CCLLocationManager *)manager...
確保locationManager已完成然後執行請求
我的網址請求在找到位置之前發生。最新最好的辦法:
- 請求位置
- 存放在字符串
- 發送串請求
我希望確保該位置其發送之前找到。我是否使用條件檢查類的實例,並在塊內部檢查服務器。我不需要不斷更新,只要抓住一次,stopUpdatingLocation
正想通過這個帖子之前:Getting Longitude/Latitude of the User When the viewDidLoad
我到目前爲止有:關於如何做到這一點
- (void)viewDidLoad {
[super viewDidLoad];
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
[locationManager startUpdatingLocation];
...more below... server request below here
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSLog(@"didUpdateToLocation: %@", newLocation);
CLLocation *currentLocation = newLocation;
if (currentLocation != nil) {
NSLog(@"found!");
[locationManager stopUpdatingLocation];
}
}
的思考?我認爲條件可能會起作用,但不確定是否有適當的方法來處理使用CoreLocation提供的方法。
哦,很高興知道。在這個應用案例中,我顯示潮汐,因此它最近的感謝上帝的潮汐站點不需要超級準確的讀數,但是不管這些仍然是我在將數據返回給用戶之前應該考慮的事情。欣賞它。 – Coughlin