From ffce46cae6cdc3a4b952a0aeca80b5d5f7304b6d Mon Sep 17 00:00:00 2001 From: Fabian Guerra Soto Date: Fri, 10 Mar 2017 14:49:22 -0800 Subject: Raise exception when MGLAnnotationView.annotation property is nil (#8339) * [ios] MGLAnnotationView annotation property made writable * [ios] standarized exception name for annotations --- platform/ios/src/MGLAnnotationView.mm | 5 ++++- platform/ios/src/MGLMapView.mm | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'platform') diff --git a/platform/ios/src/MGLAnnotationView.mm b/platform/ios/src/MGLAnnotationView.mm index 0e904779d5..5e0ae3b848 100644 --- a/platform/ios/src/MGLAnnotationView.mm +++ b/platform/ios/src/MGLAnnotationView.mm @@ -239,7 +239,10 @@ } else if (dragState == MGLAnnotationViewDragStateCanceling) { - NSAssert(self.annotation, @"Annotation property should not be nil."); + if (!self.annotation) { + [NSException raise:NSInvalidArgumentException + format:@"Annotation property should not be nil."]; + } self.panGestureRecognizer.enabled = NO; self.longPressRecognizer.enabled = NO; self.center = [self.mapView convertCoordinate:self.annotation.coordinate toPointToView:self.mapView]; diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index f0aa2804a6..8872261a88 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -1519,14 +1519,18 @@ public: return nil; } } - + // Handle the case of an offset annotation view by converting the tap point to be the geo location // of the annotation itself that the view represents for (MGLAnnotationView *view in self.annotationContainerView.annotationViews) { if (view.centerOffset.dx != 0 || view.centerOffset.dy != 0) { if (CGRectContainsPoint(view.frame, tapPoint)) { - NSAssert(view.annotation, @"Annotation's view annotation property should not be nil."); + if (!view.annotation) { + [NSException raise:NSInvalidArgumentException + format:@"Annotation view's annotation property should not be nil."]; + } + CGPoint annotationPoint = [self convertCoordinate:view.annotation.coordinate toPointToView:self]; tapPoint = annotationPoint; } -- cgit v1.2.1