新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

AFNetworking2.0使用-创新互联

AFNetworking 下载地址:https://github.com/AFNetworking/AFNetworking/AFNetworking2.0使
用

AFNetworking 2.0 当Deployment Target 低于6.0时,AFURLConnectionOperation.h,AFURLSessionManager.h

创新互联建站服务项目包括明溪网站建设、明溪网站制作、明溪网页制作以及明溪网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,明溪网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到明溪省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!
@property (nonatomic, strong) dispatch_queue_t completionQueue;

由于sdk低于6.0时,dispatch_queue_t ARC没有托管,出现提示错误

 Property with 'retain (or strong)' attribute must be of object type

修改为

#if OS_OBJECT_USE_OBJC
@property (nonatomic, strong) dispatch_queue_t completionQueue;
#else
@property (nonatomic, assign) dispatch_queue_t completionQueue;
#endif

使用示例:(不使用官方的自带的json和xml解析,返回NSData)

1.0兼容版

    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer= [AFHTTPResponseSerializer serializer];
    [manager GET:@"http://www.com" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {

    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {

    }];

 2.0

    AFHTTPSessionManager *httpSessionManager =[AFHTTPSessionManager manager];
    httpSessionManager.responseSerializer= [AFHTTPResponseSerializer serializer];
    NSURLSessionDataTask*task = [httpSessionManager GET:@"http://www.com" parameters:nil success:^(NSURLSessionDataTask *task, id responseObject)
    {

    } failure:^(NSURLSessionDataTask *task, NSError *error)
    {
        
    }];

IOS SDK 4.3以上兼容版,需要使用AFNetworking-0.10.x版本

    AFHTTPClient *httpClient = [AFHTTPClient clientWithBaseURL:nil];
    [httpClient getPath:@"http://www.com" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject)
     {

     } failure:^(AFHTTPRequestOperation *operation, NSError *error)
     {

     }];

本文名称:AFNetworking2.0使用-创新互联
文章转载:http://www.wjwzjz.com/article/dceege.html
在线咨询
服务热线
服务热线:028-86922220
TOP