首页 > 学院 > 开发设计 > 正文

AFNetWorking简单使用方法

2019-11-14 18:03:56
字体:
来源:转载
供稿:网友

                        //网络POSt请求
                        AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
                        // 设置接受数据格式
                        [manager.responseSerializer setAcceptableContentTypes: [NSSet setWithObjects:@"application/json", @"text/json",@"text/javascript",@"text/html",@"text/CSS", nil]];
                        // 设置请求格式
                        manager.requestSerializer = [AFJSONRequestSerializer serializer];
                        // 设置返回格式
                        // manager.responseSerializer = [AFJSONResponseSerializer serializer];
                        //POST网络请求

         [manager POST:apiName parameters:bodyDic success:^(AFHTTPRequestOperation *operation, id responSEObject) {

            //  success   your code

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

            //      failure    your code

             }

 


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表