AFNetworking

来源:互联网 发布:linux rpm安装java 编辑:程序博客网 时间:2024/05/23 19:39

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 


1 0
原创粉丝点击