diff --git a/include/mbgl/osx/MGLMapView.h b/include/mbgl/osx/MGLMapView.h index 7c7bea74a..df4b59784 100644 --- a/include/mbgl/osx/MGLMapView.h +++ b/include/mbgl/osx/MGLMapView.h @@ -442,7 +442,7 @@ IB_DESIGNABLE /** Deselects an annotation and hides its callout popover. @param annotation The annotation object to deselect. */ -- (void)deselectAnnotation:(id )annotation; +- (void)deselectAnnotation:(nullable id )annotation; /** A common view controller for managing a callout popover’s content view. diff --git a/platform/osx/src/MGLMapView.mm b/platform/osx/src/MGLMapView.mm index 505adb20a..57df0af6a 100644 --- a/platform/osx/src/MGLMapView.mm +++ b/platform/osx/src/MGLMapView.mm @@ -1929,7 +1929,7 @@ public: - (void)popoverDidShow:(__unused NSNotification *)notification { id annotation = self.selectedAnnotation; - if ([self.delegate respondsToSelector:@selector(mapView:didSelectAnnotation:)]) { + if (annotation && [self.delegate respondsToSelector:@selector(mapView:didSelectAnnotation:)]) { [self.delegate mapView:self didSelectAnnotation:annotation]; } }