Reputation: 2171
I am trying to add a custom value to my MKAnnotation. I would like to have it store the unique ID of the location. My code for setting up the annotation with a title and subtitle works like this:
location.latitude = [dictionary[@"placeLatitude"] doubleValue];
location.longitude = [dictionary[@"placeLongitude"] doubleValue];
newAnnotation = [[MapViewAnnotation alloc] initWithTitle:dictionary[@"placeName"]
andCoordinate:location];
newAnnotation.subtitle = dictionary[@"placeCity"];
How would I add a custom property, for example "placeId"? this is what I have:
newAnnotation.placeId=dictionary[@"placeId"];
Any help would be great. Thank you!
Upvotes: 1
Views: 1121
Reputation: 9836
If MapViewAnnotation is subclass of MKAnnotation/MKAnnotationView then simply create property for it, synthesize and use. And if not then create category over MKAnnotationView.
Here are the steps to create category class.
Then you can have "classObject.placeId" property on "classObject" object of that class.
Upvotes: 2
Reputation: 8294
Do what Bhargavi said, but do it to MapViewAnnotation.m and MapViewAnnotation.h
Upvotes: 1