[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.
This commit is contained in:
@@ -1739,7 +1739,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
|
||||
}];
|
||||
}
|
||||
|
||||
- (UIView<MGLCalloutView> *)mapView:(__unused MGLMapView *)mapView calloutViewForAnnotation:(id<MGLAnnotation>)annotation
|
||||
- (nullable id <MGLCalloutView>)mapView:(__unused MGLMapView *)mapView calloutViewForAnnotation:(id<MGLAnnotation>)annotation
|
||||
{
|
||||
if ([annotation respondsToSelector:@selector(title)]
|
||||
&& [annotation isKindOfClass:[MBXCustomCalloutAnnotation class]])
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user