woot586
woot586

Reputation: 3965

When a annotation is clicked how can I pass data to its view controller?

When an MKAnnotation is clicked I need to call a function in its view controller, and pass it two NSStrings contained in the annotation. How can I achieve this?

Upvotes: 0

Views: 303

Answers (2)

omz
omz

Reputation: 53561

Just assign your view controller as the map view's delegate and implement

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view

MKAnnotationView has an annotation property that you can use to get your strings.

Upvotes: 2

Paul
Paul

Reputation: 3010

Probably the annotations are some kind of buttons? In this case, they are the sender of the action -> A reference to the clicked annotation is passed as argument to the called function!

Upvotes: 0

Related Questions