I am trying to query the distance of my users. I can do so with this code
PFGeoPoint.geoPointForCurrentLocationInBackground { (geoPoint: PFGeoPoint?, error: NSError?) -> Void in
let query = PFUser.query()
query?.whereKey("location", nearGeoPoint: geoPoint!, withinKilometers: 1.0)
What I am trying to do is that when the user sets a slider value that this value is used instead of 1.0 as seen above. I was attempting to do this with this code: This is the slider code:
var distanceSearch: String?
@IBAction func kmSliderValueChanged(sender: UISlider) {
let kmCurrentValue = Int(sender.value)
kmLabelUpdate.text = "\(kmCurrentValue)km"
distanceSearch = "\(kmCurrentValue)"
}
And then this is the query line:
query?.whereKey("location", nearGeoPoint: geoPoint!, withinKilometers: distanceSearch!)
It is returning an error on the query line:
cannot convert value of type String to expected argument type Double
So I need to convert the slider kmCurrentValue to a double but I don't understand how to do this from reading the other SO questions. I am still new enough to coding in general. Can someone tell me what it is I need to do?