Created
June 14, 2012 19:17
-
-
Save andreortiz82/2932325 to your computer and use it in GitHub Desktop.
Callback block method with success:fail params
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
/* | |
===================================================== | |
GetPlayer:Dribbble | |
===================================================== | |
*/ | |
- (void)getPlayer:(NSString*)playername success:(void (^)(NSMutableDictionary *deals))success failure:(void (^)(NSError *error))failure | |
{ | |
NSLog(@"Dribbble test"); | |
NSURL *url = [NSURL URLWithString:@"http://api.dribbble.com/players/"]; | |
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url]; | |
NSURLRequest *request = [httpClient requestWithMethod:@"GET" path:playername parameters:nil]; | |
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { | |
if (success) { | |
success(JSON); | |
} | |
} failure:^(NSURLRequest *request , NSURLResponse *response , NSError *error , id JSON) { | |
if (failure) { | |
failure(error); | |
} | |
}]; | |
[operation start]; | |
} | |
/* | |
===================================================== | |
GetPlayer:Dribbble Implementation | |
===================================================== | |
*/ | |
[self.service getPlayer:@"andreortiz" success:^(NSMutableDictionary *deals) { | |
NSLog(@"viewDidLoad:success %@", deals); | |
} failure:^(NSError *error) { | |
NSLog(@"viewDidLoad:failure %@", error); | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment