I am running Parse Server and trying to log a user in and then update their location. Right now I am just manually creating a PFGeoPoint and then trying to add it to the key "location" which I have already added on Parse Server as a PFGeoPoint. When I run the following code I receive an error.
let currentUser = PFUser.logInWithUsername(inBackground: "test", password: "test")
let point = PFGeoPoint(latitude: 25.000, longitude: 25.000)
currentUser.setValue(point, forKey:"location")
The error is as follows:
'NSUnknownKeyException', reason: '[<BFTask 0x60000067da00> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key location.'
How can I resolve this error? Any help would be much appreciated! I am using Xcode 8 and 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)
}
}
here is method that is use for find the user current location and pass that data to your server with your PFGeoPoint that task is perform in Background. here i also mention that if your location changes or get it so in server PFUser update their location with new one . hope you are little clear about this.
thank you.