1

In my UIViewController I use both MKMapView and a MGLMapView. I need to use both of their delegate methods including mapView:didAddAnnotationViews: which is named the same for both maps. Xcode doesn't like this:

enter image description here

Is it possible to use both of these delegate methods in the same viewController?

Nic Hubbard
  • 41,587
  • 63
  • 251
  • 412

1 Answers1

1

I'm not sure if this will work, but you could try declaring the method just once, like this:

- (void)mapView:(id)mapView didAddAnnotationViews:(id)views {}

And inside the method you check the class of the mapView and do what you must do in each case

  • I thought that it had worked, but on closer inspection when the method is called by each map it does not send the `views`. – Nic Hubbard Jun 23 '17 at 19:05
  • 1
    Well, you'll need to create two different delegates, for each map then. In your viewController you instantiate them and implement your own protocol. – Felippe Bertges Jun 23 '17 at 19:58