Merge pull request #1748 from mapbox/1ec5-null-change

Avoid null-change KVO notifications
This commit is contained in:
Justin R. Miller
2015-06-17 21:37:21 -07:00
2 changed files with 7 additions and 2 deletions

View File

@@ -21,7 +21,10 @@
if (shownInAppNumber) {
[MGLAccountManager sharedManager].mapboxMetricsEnabledSettingShownInApp = [shownInAppNumber boolValue];
}
self.accessToken = [bundle objectForInfoDictionaryKey:@"MGLMapboxAccessToken"];
NSString *accessToken = [bundle objectForInfoDictionaryKey:@"MGLMapboxAccessToken"];
if (accessToken.length) {
self.accessToken = accessToken;
}
}
// Can be called from any thread.

View File

@@ -1290,7 +1290,9 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration)
if ([keyPath isEqualToString:@"accessToken"] && object == [MGLAccountManager sharedManager])
{
NSString *accessToken = change[NSKeyValueChangeNewKey];
_mbglFileSource->setAccessToken(accessToken ? (std::string)[accessToken UTF8String] : "");
if (![accessToken isKindOfClass:[NSNull class]]) {
_mbglFileSource->setAccessToken((std::string)[accessToken UTF8String]);
}
}
}