Skip to content

Instantly share code, notes, and snippets.

@j796160836
Last active August 29, 2015 13:56
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 j796160836/9317000 to your computer and use it in GitHub Desktop.
Save j796160836/9317000 to your computer and use it in GitHub Desktop.
NSURL *URL = [NSURL URLWithString:@"http://example.com/"];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
AFHTTPRequestOperation *op = [[AFHTTPRequestOperation alloc] initWithRequest:request];
op.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
op.responseSerializer =[AFHTTPResponseSerializer serializer];
[op setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
// NSString* newStr = [NSString stringWithUTF8String:[responseObject bytes]];
NSString* newStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
NSLog(@"HTML: %@", newStr);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
[[NSOperationQueue mainQueue] addOperation:op];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment