Making Controller Delegate of MapView?


#1

In the section “Being a MapView Delegate”, I couldn’t find where in the book you make the controller the delegate for the map view.

I ended up making the -(void) viewDidLoad method as follows…

  • (void)viewDidLoad
    {
    [super viewDidLoad];
    [worldView setDelegate:self];
    [worldView setShowsUserLocation:YES];
    }

Is there someplace in the chapter you described this or did I skim and not read?

  • Paul

#2

We assign the delegate by making a connection between MKMapView and File Owner on the XIB layout screen.
Instead of putting a setDelegate method in your code, open the canvas and control-click on the MKMapView. Drag it to the File Owner and set the action to delegate.

Reference Figure 5.4 on page 107 of the third edition for more information.