I have a MKMapView. In this view I create some annotations. When the user clicks on the annotation disclosure button, I want to push to the detail view.
When I create the annotation, I also fill a NSMutableDictionary to be able to grab the store object afterwards with the point as key.
MKPointAnnotation *point = [[MKPointAnnotation alloc] init];
CLLocationCoordinate2D annotationCoord;
annotationCoord.latitude = [[store storeLatitude] floatValue];
annotationCoord.longitude = [[store storeLongitude] floatValue];
point.coordinate = annotationCoord;
NSString *title = [store storeName];
point.title = title;
point.subtitle = location;
// keep reference to store object with the annotation point as key
[annotationStoreDictionary setObject:store forKey:point];
When the user selects the annotation, I want to call the DetailViewController and pass the object:
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
DetailViewController *con = [storyboard instantiateViewControllerWithIdentifier:@"DetailViewController"];
Store *store = [annotationStoreDictionary objectForKey:view.annotation];
con.store = store;
[[self navigationController] pushViewController:con animated:YES];
}
The problem is that MKPointAnnotation is not compliant with the NSCoping protocol. It says:
Sending 'MKPointAnnotation *__strong' to parameter of incompatible type 'id<NSCoping>'
How can this be fixed?