在此找到多個帖子,但仍然無法將它拼湊在一起。解析geoPointForCurrentLocationInBackground Swift示例
我正在使用分析檢索用戶的當前位置。文檔使它看起來非常簡單,但似乎缺少了幾件事情。 https://parse.com/docs/ios/guide#geopoints-getting-the-user-39-s-current-location
首先,我的代碼:
class TableViewController: UITableViewController, CLLocationManagerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
print("Get GPS")
PFGeoPoint.geoPointForCurrentLocationInBackground { (geoPoint, error) -> Void in
if error == nil {
print("Got geoPoint") //Never reaches this
print(geoPoint)
} else {
print(error) //No error either
}
}
- 我已經更新了NSLocationWhenInUseUsageDescription在我的info.plist
- 嘗試模擬器和兩個真正的設備。
- 新增CLLocationManagerDelegate
我試圖避免這複雜得多,它需要的。
我也試過使用CLLocationManager示例,它似乎也沒有工作。
我正在使用最新版本的所有內容......昨天開始使用Parse!
我從來沒有被授權使用我的位置的挑戰。試着用CLLocationManager的例子!
非常感謝一些指導/支持。
如何更新位置,geoPointForCurrentLocationInBackground檢索到的'geoPoint'?換句話說,如果用戶打開應用程序並調用此方法,那麼用戶將移動到新位置,如何將geoPoint設置爲新位置? – dnadri