Created
November 16, 2013 20:40
-
-
Save alexfish/7505005 to your computer and use it in GitHub Desktop.
Sample method to get the URL for the mock backend provided by sinatra and calasmash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (NSURL *)calabashAPIURL | |
{ | |
NSString *apiURLString = nil; | |
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"server_config" ofType:@"plist"]; | |
NSDictionary *serverConfig = [NSDictionary dictionaryWithContentsOfFile:plistPath]; | |
NSString *urlString = [serverConfig objectForKey:(NSString *)kURLPreference]; | |
if(urlString.length > 0) | |
{ | |
if(![urlString hasPrefix:@"http://"]) | |
{ | |
apiURLString = [NSString stringWithFormat:@"http://%@", urlString]; | |
} | |
else | |
{ | |
apiURLString = urlString; | |
} | |
NSString *portString = [serverConfig objectForKey:(NSString *)kPortPreference]; | |
if(portString) | |
{ | |
apiURLString = [apiURLString stringByAppendingString:[NSString stringWithFormat:@":%@",portString]]; | |
} | |
} | |
return [NSURL URLWithString:apiURLString]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment