Authored by Justin R. Miller

refs #568: attempt to hint to Swift compiler about singleton constructor

... ... @@ -32,9 +32,13 @@
/** @name Accessing the Configuration */
/** Access the shared instance of the configuration.
* @return The shared configuration instance. */
+ (instancetype)sharedInstance;
/** Access the shared instance of the configuration.
* @return The shared configuration instance. */
+ (instancetype)configuration;
+ (instancetype)configuration DEPRECATED_MSG_ATTRIBUTE("use +[RMConfiguration sharedInstance]");
- (RMConfiguration *)initWithPath:(NSString *)path;
... ...
... ... @@ -37,7 +37,7 @@ static RMConfiguration *RMConfigurationSharedInstance = nil;
cachePolicy:request.cachePolicy
timeoutInterval:request.timeoutInterval];
[newRequest setValue:[[RMConfiguration configuration] userAgent] forHTTPHeaderField:@"User-Agent"];
[newRequest setValue:[[RMConfiguration sharedInstance] userAgent] forHTTPHeaderField:@"User-Agent"];
return [NSURLConnection sendSynchronousRequest:newRequest returningResponse:response error:error];
}
... ... @@ -52,7 +52,7 @@ static RMConfiguration *RMConfigurationSharedInstance = nil;
{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:aURL];
[request setValue:[[RMConfiguration configuration] userAgent] forHTTPHeaderField:@"User-Agent"];
[request setValue:[[RMConfiguration sharedInstance] userAgent] forHTTPHeaderField:@"User-Agent"];
return [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
}
... ... @@ -67,7 +67,7 @@ static RMConfiguration *RMConfigurationSharedInstance = nil;
{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setValue:[[RMConfiguration configuration] userAgent] forHTTPHeaderField:@"User-Agent"];
[request setValue:[[RMConfiguration sharedInstance] userAgent] forHTTPHeaderField:@"User-Agent"];
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:error];
... ... @@ -89,7 +89,7 @@ static RMConfiguration *RMConfigurationSharedInstance = nil;
@synthesize userAgent=_userAgent;
@synthesize accessToken=_accessToken;
+ (instancetype)configuration
+ (instancetype)sharedInstance
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
... ... @@ -99,6 +99,11 @@ static RMConfiguration *RMConfigurationSharedInstance = nil;
return RMConfigurationSharedInstance;
}
+ (instancetype)configuration
{
return [[self class] sharedInstance];
}
- (RMConfiguration *)initWithPath:(NSString *)path
{
if (!(self = [super init]))
... ...
... ... @@ -184,8 +184,8 @@
- (NSURL *)canonicalURLForMapID:(NSString *)mapID
{
NSString *version = ([[RMConfiguration configuration] accessToken] ? @"v4" : @"v3");
NSString *accessToken = ([[RMConfiguration configuration] accessToken] ? [@"&access_token=" stringByAppendingString:[[RMConfiguration configuration] accessToken]] : @"");
NSString *version = ([[RMConfiguration sharedInstance] accessToken] ? @"v4" : @"v3");
NSString *accessToken = ([[RMConfiguration sharedInstance] accessToken] ? [@"&access_token=" stringByAppendingString:[[RMConfiguration sharedInstance] accessToken]] : @"");
return [NSURL URLWithString:[NSString stringWithFormat:@"https://api.tiles.mapbox.com/%@/%@.json?secure%@", version, mapID, accessToken]];
}
... ... @@ -358,7 +358,7 @@
+ (BOOL)isUsingLargeTiles
{
return ([[RMConfiguration configuration] accessToken] && [[UIScreen mainScreen] scale] > 1.0);
return ([[RMConfiguration sharedInstance] accessToken] && [[UIScreen mainScreen] scale] > 1.0);
}
- (NSString *)uniqueTilecacheKey
... ...
... ... @@ -140,8 +140,8 @@
- (id)initWithMapboxMarkerImage:(NSString *)symbolName tintColorHex:(NSString *)colorHex sizeString:(NSString *)sizeString
{
NSString *version = ([[RMConfiguration configuration] accessToken] ? @"v4" : @"v3");
NSString *accessToken = ([[RMConfiguration configuration] accessToken] ? [@"?access_token=" stringByAppendingString:[[RMConfiguration configuration] accessToken]] : @"");
NSString *version = ([[RMConfiguration sharedInstance] accessToken] ? @"v4" : @"v3");
NSString *accessToken = ([[RMConfiguration sharedInstance] accessToken] ? [@"?access_token=" stringByAppendingString:[[RMConfiguration sharedInstance] accessToken]] : @"");
BOOL useRetina = ([[UIScreen mainScreen] scale] > 1.0);
NSURL *imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://api.tiles.mapbox.com/%@/marker/pin-%@%@%@%@.png%@",
... ...
... ... @@ -78,7 +78,7 @@
_activeTileSource = nil;
_backgroundFetchQueue = nil;
id cacheCfg = [[RMConfiguration configuration] cacheConfiguration];
id cacheCfg = [[RMConfiguration sharedInstance] cacheConfiguration];
if (!cacheCfg)
cacheCfg = [NSArray arrayWithObjects:
[NSDictionary dictionaryWithObject: @"memory-cache" forKey: @"type"],
... ...