Skip to content

Instantly share code, notes, and snippets.

@steveoleary
Forked from sspencer/AFNetworkingRequest.m
Created March 9, 2012 16:29
Show Gist options
  • Save steveoleary/2007358 to your computer and use it in GitHub Desktop.
Save steveoleary/2007358 to your computer and use it in GitHub Desktop.
AFNetworking Request
// using ARC, so no release / autorelease
AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:@"http://localhost"]];
NSURLRequest *request = [client requestWithMethod:@"GET" path:@"/auth.php" parameters:nil];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[client HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"success: %@", operation.responseString);
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"error: %@", operation.error);
}
];
[httpClient enqueueHTTPRequestOperation:operation];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment