0

I want to override the viewForAnnotation method provided by the delegate.

I want to pass 1 more argument, type, so that I can change the color of pins according to the kind of annotation.

For ex: I would want it to be viewForAnnotation:type:.

Any help ?

Hrishikesh Choudhari
  • 11,617
  • 18
  • 61
  • 74

1 Answers1

1

Don't try to "override"/replace the viewForAnnotation delegate method.

Instead, add whatever properties you need to your class that implements the MKAnnotation protocol (the one you instantiate to pass to the addAnnotation method).

Then in the standard viewForAnnotation method, you can access your custom properties in the annotation parameter that is passed. You should first check if the annotation's class is your custom class and then cast it before trying to reference the custom properties.

If you're using the pre-defined MKPointAnnotation class for your annotations, you'll have to switch to your own custom class.