解析和 Swift 地理点未保存

Parse and Swift Geopoints not saving

我什么都试过了。无论使用带有 xcode 的实际设备还是使用模拟器,我的 Geopoints 都不会保存。

if signUpError == nil {
   PFGeoPoint.geoPointForCurrentLocationInBackground {
   (geoPoint: PFGeoPoint?, error: NSError?) -> Void in
     if error == nil {
        PFUser.currentUser()!.setValue(geoPoint, forKey: "location")
      }
}

我不知道该怎么做。

那是因为你正在设置它,但你没有保存刚刚设置的值:

if signUpError == nil {
   PFGeoPoint.geoPointForCurrentLocationInBackground {
   (geoPoint: PFGeoPoint?, error: NSError?) -> Void in
     if error == nil {
        PFUser.currentUser()!.setValue(geoPoint, forKey: "location")
        PFUser.currentUser().saveInBackground() 
      }
}