Created
December 4, 2013 08:05
-
-
Save yaoxinghuo/7783848 to your computer and use it in GitHub Desktop.
AFNetoworking HelloWorld
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
//依赖包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