Hi i am using afnetworking 2.0 in my project. I need to post with json dic as parameter. In earlier version afhttpclient there is AFJSONParameterEncoding. How to do it in latest version?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Right now you need to use serializer classes for your reuqest manager
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
[manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];