* [ios, macos] Fixed static analyzer warnings Fixed static analyzer warnings in MGLNetworkConfiguration, MGLRasterSource, and MGLShape. * [ios] Fixed static analyzer warnings Fixed static analyzer warnings in MGLAnnotationImage. * [macos] Fixed static analyzer warnings Fixed static analyzer warnings in MGLAnnotationImage and NSImage(MGLAdditions). * [ios, macos] Two pointer-equal images are object-equal by definition
40 lines
1.0 KiB
Objective-C
40 lines
1.0 KiB
Objective-C
#import "MGLNetworkConfiguration.h"
|
|
|
|
@implementation MGLNetworkConfiguration
|
|
|
|
+ (void)load {
|
|
// Read the initial configuration from Info.plist.
|
|
NSString *apiBaseURL = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"MGLMapboxAPIBaseURL"];
|
|
if (apiBaseURL.length) {
|
|
[self setAPIBaseURL:[NSURL URLWithString:apiBaseURL]];
|
|
}
|
|
}
|
|
|
|
+ (instancetype)sharedManager {
|
|
static dispatch_once_t onceToken;
|
|
static MGLNetworkConfiguration *_sharedManager;
|
|
void (^setupBlock)() = ^{
|
|
dispatch_once(&onceToken, ^{
|
|
_sharedManager = [[self alloc] init];
|
|
});
|
|
};
|
|
if (![[NSThread currentThread] isMainThread]) {
|
|
dispatch_sync(dispatch_get_main_queue(), ^{
|
|
setupBlock();
|
|
});
|
|
} else {
|
|
setupBlock();
|
|
}
|
|
return _sharedManager;
|
|
}
|
|
|
|
+ (void)setAPIBaseURL:(NSURL *)apiBaseURL {
|
|
[MGLNetworkConfiguration sharedManager].apiBaseURL = apiBaseURL;
|
|
}
|
|
|
|
+ (NSURL *)apiBaseURL {
|
|
return [MGLNetworkConfiguration sharedManager].apiBaseURL;
|
|
}
|
|
|
|
@end
|