Graphics Programs Reference
In-Depth Information
Build and run the application again. Select a location from the debugger bar. The map will
then zoom in on this location.
This is pretty standard workflow for iOS programming: you want an object to do
something and you follow the bread crumbs in the API Reference. There will be dead
ends and wild goose chases, but eventually you'll find what you need. As you go through
this topic, don't hesitate to look up the classes, protocols, and methods we use to see what
else they can do. You want to become as comfortable as possible with the API Reference.
The more you use it, the easier it will be to progress as an iOS developer. You cannot be
an iOS developer without using the API Reference.
Apple will continue to update the iOS SDK and introduce iOS devices with new features
and capabilities. If you are comfortable using Apple's documentation, you will be ready
for whatever Apple dreams up in the future.
Your own MKAnnotation
Now that Whereami displays a nicely-zoomed map of the current location, we can turn to
adding annotations. Let's start with an introduction to the MKAnnotation protocol.
MKAnnotation is not a delegate protocol. Instead, it declares a set of methods that are
useful to any class that wants to display instances of itself on a map view. Imagine an ap-
plication that maps everything in a neighborhood, including restaurants, factories, and
train stations. These classes could be very different and hierarchically unrelated in the ap-
plication, but if they conform to MKAnnotation , they all can be added to an
MKMapView .
When an object conforming to MKAnnotation is added to an MKMapView , an instance
of MKAnnotationView (or one of its subclasses) is created and added to the map view.
The MKAnnotationView keeps a pointer to the MKAnnotation -conforming object
that it represents so it can ask it for data as needed. The relationships between these ob-
jects are shown in Figure 5.13 .
Figure 5.13 MKMapView and its annotations
 
Search WWH ::




Custom Search