diff options
author | Jesse Bounds <jesse@rebounds.net> | 2017-04-04 15:25:59 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-04 15:25:59 -0700 |
commit | ff7337121685b1ff091468dc96cfc23e567ab029 (patch) | |
tree | 5a7d99a4fb5d97c3b7309cad4fcd11b6db84a47f /platform/ios/src | |
parent | e34b4718422438af365fe5ede67d1c490e95d9cc (diff) | |
download | qtlocation-mapboxgl-ff7337121685b1ff091468dc96cfc23e567ab029.tar.gz |
[ios] Silence incompatible type warning for callout view (#8608)
This silences a compatibility warning that was introduced in a previous
refactor that changed the return type of the callout view for
annotation delegate method. This also adds checks to ensure that the
callout view provided by the delegate to the map view is of the correct
type and conforms to the correct protocol.
Diffstat (limited to 'platform/ios/src')
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 79467a065f..6f51d4b523 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -3777,7 +3777,14 @@ public: UIView <MGLCalloutView> *calloutView; if ([self.delegate respondsToSelector:@selector(mapView:calloutViewForAnnotation:)]) { - calloutView = [self.delegate mapView:self calloutViewForAnnotation:annotation]; + id providedCalloutView = [self.delegate mapView:self calloutViewForAnnotation:annotation]; + if (providedCalloutView) { + if (![providedCalloutView isKindOfClass:[UIView class]]) { + [NSException raise:NSInvalidArgumentException format:@"Callout view must be a kind of UIView"]; + } + NSAssert([providedCalloutView conformsToProtocol:@protocol(MGLCalloutView)], @"callout view must conform to MGLCalloutView"); + calloutView = providedCalloutView; + } } if (!calloutView) { |