Skip to content

Instantly share code, notes, and snippets.

@kerin
Created October 31, 2012 13:58
Show Gist options
  • Save kerin/3987169 to your computer and use it in GitHub Desktop.
Save kerin/3987169 to your computer and use it in GitHub Desktop.
- (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