summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2015-05-13 16:08:40 -0700
committerMinh Nguyễn <mxn@1ec5.org>2015-05-13 16:08:40 -0700
commitcbb7112e8c2a79a4777a1e439029686dc3e3547e (patch)
tree313bcbbb4a013f4cccf5c15a2c8b70af929f1ec1 /platform
parent2529baa62b509f2c763d5b3f9f5e1e388a45917f (diff)
downloadqtlocation-mapboxgl-cbb7112e8c2a79a4777a1e439029686dc3e3547e.tar.gz
Set up MGLAccountManager without any prodding
`MGLAccountManager` is now guaranteed to initialize without the code ever making any mention of it. It also is guaranteed to be set up before `MGLMapboxMetrics` but will definitely cause `MGLMapboxMetrics` to be set up on the main thread if the access token is set in Info.plist.
Diffstat (limited to 'platform')
-rw-r--r--platform/ios/MGLAccountManager.m18
1 files changed, 8 insertions, 10 deletions
diff --git a/platform/ios/MGLAccountManager.m b/platform/ios/MGLAccountManager.m
index 819dd741d9..d5b89e9f99 100644
--- a/platform/ios/MGLAccountManager.m
+++ b/platform/ios/MGLAccountManager.m
@@ -16,15 +16,13 @@
@implementation MGLAccountManager
-+ (void)initialize {
- if (self == [MGLAccountManager class]) {
- // Read initial configuration from Info.plist.
- NSBundle *bundle = [NSBundle bundleForClass:self];
- self.accessToken = [bundle objectForInfoDictionaryKey:@"MGLMapboxAccessToken"];
- NSNumber *shownInAppNumber = [bundle objectForInfoDictionaryKey:@"MGLMapboxMetricsEnabledSettingShownInApp"];
- if (shownInAppNumber) {
- [MGLAccountManager sharedManager].mapboxMetricsEnabledSettingShownInApp = [shownInAppNumber boolValue];
- }
++ (void)load {
+ // Read initial configuration from Info.plist.
+ NSBundle *bundle = [NSBundle bundleForClass:self];
+ self.accessToken = [bundle objectForInfoDictionaryKey:@"MGLMapboxAccessToken"];
+ NSNumber *shownInAppNumber = [bundle objectForInfoDictionaryKey:@"MGLMapboxMetricsEnabledSettingShownInApp"];
+ if (shownInAppNumber) {
+ [MGLAccountManager sharedManager].mapboxMetricsEnabledSettingShownInApp = [shownInAppNumber boolValue];
}
}
@@ -63,7 +61,7 @@
+ (void) setAccessToken:(NSString *) accessToken {
if ( ! [accessToken length]) return;
- [[MGLAccountManager sharedManager] setAccessToken:accessToken];
+ [MGLAccountManager sharedManager].accessToken = accessToken;
// Update MGLMapboxEvents
// NOTE: This is (likely) the initial setup of MGLMapboxEvents