From 563fed5ca93273342366c54be8f619c12b514417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Sat, 16 May 2015 20:26:28 -0700 Subject: [PATCH] Properly fail to load the map A typo in a selector literal meant that `-[MGLMapViewDelegate mapViewDidFailLoadingMap:withError:]` would never be sent to delegates even if `MGLMapView` had called it. Along for the ride, create a proper `NSError` to pass into that callback, and an error domain for that error. --- gyp/platform-ios.gypi | 1 + include/mbgl/ios/MGLTypes.h | 2 ++ platform/ios/MGLMapView.mm | 5 +++-- platform/ios/MGLTypes.m | 3 +++ 4 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 platform/ios/MGLTypes.m diff --git a/gyp/platform-ios.gypi b/gyp/platform-ios.gypi index 7e91648c4..0e200f5e1 100644 --- a/gyp/platform-ios.gypi +++ b/gyp/platform-ios.gypi @@ -35,6 +35,7 @@ '../platform/ios/MGLUserLocationAnnotationView.h', '../platform/ios/MGLUserLocationAnnotationView.m', '../include/mbgl/ios/MGLTypes.h', + '../platform/ios/MGLTypes.m', '../platform/ios/NSBundle+MGLAdditions.h', '../platform/ios/NSBundle+MGLAdditions.m', '../platform/ios/NSException+MGLAdditions.h', diff --git a/include/mbgl/ios/MGLTypes.h b/include/mbgl/ios/MGLTypes.h index 9a393b2fd..d4bc6c2ce 100644 --- a/include/mbgl/ios/MGLTypes.h +++ b/include/mbgl/ios/MGLTypes.h @@ -1,5 +1,7 @@ #import +extern NSString * const MGLErrorDomain; + /** The mode used to track the user location on the map. */ typedef NS_ENUM(NSUInteger, MGLUserTrackingMode) { diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index ff31ec9e1..dfbb03439 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -2352,9 +2352,10 @@ CLLocationCoordinate2D latLngToCoordinate(mbgl::LatLng latLng) } case mbgl::MapChangeDidFailLoadingMap: { - if ([self.delegate respondsToSelector:@selector(mapViewDidFailLoadingMap:withError::)]) + if ([self.delegate respondsToSelector:@selector(mapViewDidFailLoadingMap:withError:)]) { - [self.delegate mapViewDidFailLoadingMap:self withError:nil]; + NSError *error = [NSError errorWithDomain:MGLErrorDomain code:0 userInfo:nil]; + [self.delegate mapViewDidFailLoadingMap:self withError:error]; } break; } diff --git a/platform/ios/MGLTypes.m b/platform/ios/MGLTypes.m new file mode 100644 index 000000000..01e9a1467 --- /dev/null +++ b/platform/ios/MGLTypes.m @@ -0,0 +1,3 @@ +#import "MGLTypes.h" + +NSString * const MGLErrorDomain = @"MGLErrorDomain";