Created
October 15, 2014 15:53
-
-
Save iandundas/697732f20a7fd6907bf9 to your computer and use it in GitHub Desktop.
How to make a POST in #AFNetworking
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
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; | |
NSDictionary *parameters = @{@"name": @"Ian"}; | |
[manager POST:@"http://google.com" | |
parameters:parameters | |
success:^(AFHTTPRequestOperation *operation, id responseObject) { | |
// e.g. responseObject[@"user"]; | |
} failure:^(AFHTTPRequestOperation *operation, NSError *error) { | |
NSData *data= error.userInfo[AFNetworkingOperationFailingURLResponseDataErrorKey]; | |
NSString *failureResponse = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; | |
NSLog(@"Failure response: %@", failureResponse); | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment