Graphics Programs Reference
In-Depth Information
For now, assume there is a “zoom-in-on-location” message you can send to an instance of
MKMapView . The question is when would you send that message? When the application
starts, it takes time for the device to determine the location. So you can't send it in
initWithNibName:bundle: because you don't yet know the location to zoom in on.
Nor do you want to continually tell the MKMapView to zoom its map; that would be inef-
ficient.
Instead, how about delegation? MKMapView has a delegate property that you set to be
the instance of WhereamiViewController . In WhereamiViewController.h ,
declare that WhereamiViewController conforms to the MKMapViewDelegate
protocol.
@interface WhereamiViewController : UIViewController
<CLLocationManagerDelegate , MKMapViewDelegate >
{
The map view will send messages to its delegate when interesting events happen. Perhaps
there is a message in the MKMapViewDelegate protocol for when the map view finds
the user's location. Finding the location is an interesting event, and it would be the perfect
time to “do the zoom.” We can find out if the protocol declares such a message in the
Apple documentation.
Using the documentation
There's nothing more important we can teach you than how to use the Apple documenta-
tion. So hang on as we tackle - step-by-step - the questions of when and how to display a
zoomed-in map of the current location.
The documentation is divided into four parts: API Reference, System Guides, Tools
Guides, and Sample Code. The API Reference shows you every class, protocol, function,
structure, method, and anything else you may use from Cocoa Touch. The System Guides
give you high-level overviews and discussion about concepts in Cocoa Touch. The Tools
Guide is the manual for Xcode and the rest of the developer tools suite.
While all four parts are useful, the API Reference is absolutely essential to everyday pro-
gramming. There are so many classes and methods built into Cocoa Touch that it is im-
possible for a developer to remember them all. At no point in your iOS developer career
will you outgrow the API Reference.
Search WWH ::




Custom Search