AFNetworking

AFNetworking是一款用于iOS和macOS的高效网络库,基于Foundation URL Loading System构建,并对其进行了扩展,提供强大的高级网络抽象功能。它采用模块化架构,拥有精心设计且功能丰富的API。AFNetworking支持下载、上传(包括进度显示的multipart请求)、网络状态检测等功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值