AFNetworking is a delightful networking library for iOS and Mac OS X. It's built on top of the Foundation URL Loading System. System, extending the powerful high-level networking abstractions built into Cocoa. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use.
Perhaps the most important feature of all, however, is the amazing community of developers who use and contribute to AFNetworking every day. AFNetworking powers some of the most popular and critically-acclaimed apps on the iPhone, iPad, and Mac.
Choose AFNetworking for your next project, or migrate over your existing projects—you'll be happy you did.
AFNetworking is based on NSURLSession. If you want to know about NSURLSession click http://blog.csdn.net/djl4104804/article/details/22667273 ( difference of NSURLSession and NSURLConnection )
AFNetworking can download, upload (for mute-part Request, with progress) ,network state detection...(more...)
first the download task
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
NSURL *URL = [NSURL URLWithString:@"http://www.baidu.com"];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
NSURLSessionDataTask *dataTask = [manager dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
if (error) {
NSLog(@"Error: %@", error);
} else {
NSLog(@"%@ %@", response, responseObject);
}
}];
[dataTask resume];//resume tesk if it is suspended
I will
update AFNetworking code later one by one. QAQ