使用 Xcode 8 和 Swift 3 在 Parse 中更新用户位置

Update User Location In Parse Using Xcode 8 and Swift 3

我正在 运行 宁 解析服务器 并尝试让用户登录然后 更新他们的位置 。现在我只是手动创建一个 PFGeoPoint 然后尝试将它添加到我已经在 Parse Server 上添加的键“location”一个 PFGeoPoint。当我 运行 以下代码时,我收到一个错误。

 let currentUser = PFUser.logInWithUsername(inBackground: "test", password: "test")
 let point = PFGeoPoint(latitude: 25.000, longitude: 25.000)
 currentUser.setValue(point, forKey:"location")

错误如下:

'NSUnknownKeyException', reason: '[<BFTask 0x60000067da00> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key location.'

我该如何解决这个错误?任何帮助将非常感激! 我正在使用 Xcode 8 和 Swift 3.

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

这里是用于查找用户当前位置并将该数据传递到您的服务器的方法,该任务在后台执行。在这里我还提到,如果您的位置发生变化或在服务器 PFUser 中获取它,请使用新位置更新他们的位置。希望你对此不太清楚。

谢谢。