Skip to content

Instantly share code, notes, and snippets.

@charvoa
Created December 4, 2018 21:07
Show Gist options
  • Save charvoa/3fcb6703a620c719bc71056ac01a09c6 to your computer and use it in GitHub Desktop.
Save charvoa/3fcb6703a620c719bc71056ac01a09c6 to your computer and use it in GitHub Desktop.
fetchMapLessons after Geo-pagination re-work
func fetchMapLessons(around: CLLocation,
within: Double,
_ completionHandler: @escaping ([Any]?) -> Void) {
let query = PFQuery(className: "ObjectClass")
.addAscendingOrder("date")
.whereKey("location",
nearGeoPoint: PFGeoPoint(location: around),
withinKilometers: within)
query.findObjectsInBackground { (objects, error) in
guard let obj = objects else {
completionHandler(nil)
return
}
var viewModelArray = [ObjectModel]()
obj.forEach { o in
if let model = ObjectModel(fromParseObject: o) {
viewModelArray.append(model)
}
}
completionHandler(viewModelArray)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment