MKPointAnnotation add extra property

2019-07-18 23:38发布

问题:

Is it possible to add an extra property to MKPointAnnotation? At the moment there is coordinate, title, and subtitle.

Is it possible to add a url property which can be accessed within -(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{ }, just like I can access[annotation title];?

回答1:

Just make an MKPointAnnotation subclass.

Delete all the methods out of the .m file, and add this to your .h file:

@property (nonatomic, strong) NSURL *url;