Skip to content

Instantly share code, notes, and snippets.

@syxc
Forked from fawkeswei/AFNetworking_post_json.m
Last active December 20, 2015 16:38
Show Gist options
  • Save syxc/6162358 to your computer and use it in GitHub Desktop.
Save syxc/6162358 to your computer and use it in GitHub Desktop.
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
height, @"user[height]",
weight, @"user[weight]",
nil];
AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:
[NSURL URLWithString:@"http://localhost:8080/"]];
[client postPath:@"/mypage.php" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSString *text = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
NSLog(@"Response: %@", text);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"%@", [error localizedDescription]);
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment