Skip to content

Instantly share code, notes, and snippets.

@yaoxinghuo
Created December 4, 2013 08:05
Show Gist options
  • Save yaoxinghuo/7783848 to your computer and use it in GitHub Desktop.
Save yaoxinghuo/7783848 to your computer and use it in GitHub Desktop.
AFNetoworking HelloWorld
//依赖包CoreLocation.framework, MobileCoreServices.framework, SystemConfiguration.framework, Security.framework
#import "AFNetworking.h"
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
//默认是AFJSONRequestSerializer
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
[manager GET:@"http://www.baidu.com" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSData *data = (NSData *)responseObject;
NSLog(@"JSON: %@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment