Created
November 18, 2011 23:58
-
-
Save sspencer/1378148 to your computer and use it in GitHub Desktop.
AFNetworking Request
This file contains hidden or 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
// using ARC, so no release / autorelease | |
AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:@"http://localhost"]]; | |
[client setAuthorizationHeaderWithUsername:@"steve" password:@"mypass"]; | |
NSURLRequest *request = [client requestWithMethod:@"GET" path:@"/auth.php" parameters:nil]; | |
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; | |
[operation | |
setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { | |
NSLog(@"success: %@", operation.responseString); | |
} | |
failure:^(AFHTTPRequestOperation *operation, NSError *error) { | |
NSLog(@"error: %@", operation.error); | |
} | |
]; | |
[[[NSOperationQueue alloc] init] addOperation:operation]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment