Skip to content

Instantly share code, notes, and snippets.

@charvoa
Created December 4, 2018 21:03
Show Gist options
  • Save charvoa/4fc1fab93683cb305801f9daac58aee7 to your computer and use it in GitHub Desktop.
Save charvoa/4fc1fab93683cb305801f9daac58aee7 to your computer and use it in GitHub Desktop.
fetchLessons function before geo-pagination
func fetchMapLessons(_ completionHandler: @escaping ([ObjectModel]?) -> Void) {
let query = PFQuery(className: "ObjectClass")
.addAscendingOrder("date")
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