我有一个 MKMapView。在这个视图中,我创建了一些注释。当用户单击注释披露按钮时,我想推送到详细视图。
当我创建注释时,我还填充了一个 NSMutableDictionary 以便之后能够以该点为键来获取存储对象。
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];
当用户选择注释时,我想调用 DetailViewController 并传递对象:
- (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];
}
问题是 MKPointAnnotation 不符合 NSCoping 协议。它说:
Sending 'MKPointAnnotation *__strong' to parameter of incompatible type 'id<NSCoping>'
如何解决这个问题?