How to stop rewriting CLLocationManager boilerplate in every screen — and design something your future self will actually thank you for.* If you've shipped more than a couple of iOS apps, you've written this code. Probably more than once. Maybe more than ten times. locationManager . delegate = self locationManager . requestWhenInUseAuthorization () // ...somewhere else... func locationManager ( _ manager : CLLocationManager , didUpdateLocations locations : [ CLLocation ]) { // do the thing } Enter fullscreen mode Exit fullscreen mode And every time, you end up with the same scattered mess: a CLLocationManager instance hanging off a view controller, delegate methods sprinkled in between unrelated UI code, an if ladder for authorization status, and some half-built UI for telling the user "hey, you actually need to enable location for this to work." It works. But it doesn't scale across an app. The second screen that needs location duplicates 80% of the first one.…