Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@iandundas
Created October 15, 2014 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iandundas/697732f20a7fd6907bf9 to your computer and use it in GitHub Desktop.
Save iandundas/697732f20a7fd6907bf9 to your computer and use it in GitHub Desktop.
How to make a POST in #AFNetworking
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