Created
October 31, 2012 13:58
-
-
Save kerin/3987169 to your computer and use it in GitHub Desktop.
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
- (id)makeRequestWithPath:(NSString *)path queryStringParams:(NSDictionary *)queryparams { | |
NSURL *url = [NSURL URLWithString:path relativeToURL:[LanternAPIClient baseURL]]; | |
if (queryparams) { | |
NSMutableArray *queryparts = [[NSMutableArray alloc] init]; | |
for (id key in queryparams) { | |
[queryparts addObject:[NSString stringWithFormat:@"%@=%@", | |
key, [queryparams objectForKey:key]]]; | |
} | |
NSString *querystring = [queryparts componentsJoinedByString:@"&"]; | |
url = [NSURL URLWithString:[NSString stringWithFormat:@"?%@", querystring] relativeToURL:url]; | |
} | |
NSLog(@"%@", url); | |
NSError *err = nil; | |
NSData *res = [NSData dataWithContentsOfURL:url]; | |
return [NSJSONSerialization JSONObjectWithData:res | |
options:NSJSONReadingMutableLeaves | |
error:&err]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment