In our map, we are going to drop pins down at each restaurant location. These pins are called annotations, more specifically, MKAnnotation
. Since we are going to create multiple MKAnnotation
protocols, we are going to create a class that subclasses MKAnnotation
.
MKAnnotation
is a protocol that provides us with information related to a map view. Protocols provide a blueprint for methods, properties, and other required functionalities . The MKAnnotation
will contain information, such as the coordinates (latitude and longitude), title, and subtitle of the annotation.
To drop a pin onto a map, we must subclass the MKAnnotation
. When we first looked at classes versus structs, we saw that classes could subclass or inherit from other classes, which means that we can get properties, methods, and additional requirements from the class that we are subclassing. Let's create an annotation that subclasses MKAnnotation
and see how this works.