Getting Started with MapKit

In the last chapter, you learned about table views and table view controllers, and completed the implementation of the Locations screen so it now displays a list of restaurant locations.

In this chapter, you'll display restaurant locations on the Map screen using custom pins. When users tap on a pin, they'll see a screen that shows details of a particular restaurant.

To do this, you'll create a new class, RestaurantItem, that conforms to the MKAnnotation protocol. Next, you'll create MapDataManager, a data manager that loads restaurant data from a .plist file and puts it into an array of RestaurantItem instances. You'll make changes to both MapDataManager and ExploreDataManager to avoid redundant code (refactoring).

After that, you'll create MapViewController, a view controller for the Map screen, and configure it to display custom annotations.

Next, you'll configure callout buttons in the custom annotations to display the Restaurant Detail screen. You'll create RestaurantDetailViewControllera view controller for the Restaurant Detail screen, and pass data to it from MapViewController.

Finally, you'll clean up and organize your code to make it easier to read and maintain.

By the end of this chapter, you'll have learned how to create custom map annotations and add them to a map, how to use storyboard references to link storyboards together, and how to use extensions to organize your code, making it easier to read.

The following topics will be covered:

  • Understanding and creating annotations
  • Adding annotations to a map view
  • Going from the map view to the Restaurant Detail screen
  • Organizing your code
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.108.11