你的位置:首页 > 操作系统

[操作系统]AFNetWorking 简单使用方法


                        //网络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

             }