From 7e145780ebbd5d35a74f263c51827ae2a37c4eb8 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Thu, 23 Apr 2015 18:15:01 -0500 Subject: #1225 - Initial conversion of Mapbox GL app to set access token in AppDelegate and exposing MGLMapView.initWithFrame to support it --- platform/ios/MGLMapView.mm | 2 ++ platform/ios/MapboxGL.m | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'platform') diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 5f5e99b0eb..e48b3d82dc 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -25,6 +25,7 @@ #import "SMCalloutView.h" #import "MGLMapboxEvents.h" +#import "MapboxGL.h" #import @@ -122,6 +123,7 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; if (self && [self commonInit]) { self.styleURL = nil; + self.accessToken = [MapboxGL getAccessToken]; return self; } diff --git a/platform/ios/MapboxGL.m b/platform/ios/MapboxGL.m index b1cb44cbc9..97ac8f1d5d 100644 --- a/platform/ios/MapboxGL.m +++ b/platform/ios/MapboxGL.m @@ -1,22 +1,24 @@ #import #import "MapboxGL.h" +#import "NSProcessInfo+MGLAdditions.h" @interface MapboxGL() +@property (atomic) NSString *accessToken; + @end -@property (atomic) NSString *accessToken; @implementation MapboxGL +static MapboxGL *_sharedManager; // Can be called from any thread. Called implicitly from any // public class convenience methods. // -+ (instancetype) sharedInstanceWithAccessToken:(NSString *)token { ++ (id) sharedInstanceWithAccessToken:(NSString *)token { static dispatch_once_t onceToken; - static MapboxGL *_sharedManager; dispatch_once(&onceToken, ^{ if ( ! NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent) { void (^setupBlock)() = ^{ @@ -36,4 +38,11 @@ return _sharedManager; } ++ (NSString *) getAccessToken { + if (_sharedManager) { + return _sharedManager.accessToken; + } + return nil; +} + @end \ No newline at end of file -- cgit v1.2.1