Skip to content

Instantly share code, notes, and snippets.

View charvoa's full-sized avatar
🐦
Happy Coder

Nicolas Charvoz charvoa

🐦
Happy Coder
View GitHub Profile
func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool) {
let center = mapView.region.center
let latitudeDelta = mapView.region.span.latitudeDelta
let topPin = CLLocation(latitude: center.latitude - (latitudeDelta / 2),
longitude: center.longitude)
let bottomPin = CLLocation(latitude: center.latitude + (latitudeDelta / 2),
longitude: center.longitude)
let centerLocation = CLLocation(latitude: center.latitude,
longitude: center.longitude)
@charvoa
charvoa / LessonService.swift
Created December 4, 2018 21:07
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)
@charvoa
charvoa / LessonService.swift
Created December 4, 2018 21:03
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
}