Skip to content

Instantly share code, notes, and snippets.

@ashfurrow
Created November 28, 2015 16:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashfurrow/8194c93bd049c46d73aa to your computer and use it in GitHub Desktop.
Save ashfurrow/8194c93bd049c46d73aa to your computer and use it in GitHub Desktop.
import UIKit
protocol LocationManagerDelegate {
func retrievedMapLocation(location: Int)
}
class LocationManager {
var delegate: LocationManagerDelegate?
func getLocations() {
// TODO: Get locations
let locations = [1,2,3,4]
locations.forEach { (location) -> () in
self.delegate?.retrievedMapLocation(location)
}
}
}
class ViewController: UIViewController, LocationManagerDelegate {
let manager = LocationManager()
override func viewDidLoad() {
manager.delegate = self
}
func retrievedMapLocation(location: Int) {
// TODO: Update our map
}
}
@ashfurrow
Copy link
Author

/cc @hetony

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment