AFN post形式的实用小总结

AFN post的向服务器提交数据

 AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];

    //申明返回的结果是json类型

    manager.responseSerializer = [AFJSONResponseSerializer serializer];

    //申明请求的数据是json类型

    manager.requestSerializer=[AFJSONRequestSerializer serializer];

    //如果报接受类型不一致请替换一致text/html或别的

    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];

    //传入的参数

    NSDictionary *parameters = @{@"i_name":_nameField.text,@"i_phone":_realInfo.phone,@"i_number":_cardID.text};


    

    [manager POST:urlStr parameters:parameters constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {

        

    } success:^(NSURLSessionDataTask *task, id responseObject) {

        NSLog(@"成功");

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

         NSLog(@"失败");

    }];



版权声明:本文为博主原创文章,未经博主允许不得转载。

文章来自:http://blog.csdn.net/u010070526/article/details/47024987
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3