[英]Getting Current Location using Parse SDK
我正在嘗試使用geoPointForCurrentLocation方法中的構建獲取用戶的當前位置。 我嘗試在我的User類(稱為location)中創建的自定義字段中設置geoPoint,然后嘗試使用saveInBackground方法保存它。
[PFGeoPoint geoPointForCurrentLocationInBackground: ^(PFGeoPoint *geoPoint, NSError *error) {
if (!error)
{
[[PFUser currentUser] setObject: geoPoint forKey: @"location"];
[[PFUser currentUser] saveInBackground];
}
}];
沒有引發任何錯誤,但用戶的位置未保存到數據庫。
編輯:
我的viewDidLoad方法看起來像這樣:
self.locationManager = [[[CLLocationManager alloc] init]; self.locationManager.delegate =自我;
if ([self.locationManager
respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
[self.locationManager requestWhenInUseAuthorization];
}
}
並且我為使用授權設置了info.plist密鑰。
沒有用CLLocationManagerDelegate標記我的實現文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.