Refactoring MapViewController

We are just about done refactoring our files. The last file we need to refactor is our MapViewController. Let's get started:

  1. Inside of our MapViewController, after the last curly brace, hit enter a couple of times and add the following code (remember, this should be outside of the class, not inside):
// MARK: Private Extensionprivate extension MapViewController {} // MARK: MKMapViewDelegate extension MapViewController: MKMapDelegate {}
  1. Next, remove the MKMapViewDelegate subclass from the main class and move it into our extension.
  1. Now, let's move all of our MKMapViewDelegate methods into the extension. You should be moving the following:

Your extension should now look as follows:

  1. Next, let's update our ...

Get iOS 12 Programming for Beginners - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.