iOS-AFN Post JSON格式数据
程序员文章站
2022-05-07 13:55:20
- (void)postRequest{ AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; // >>>>>>>> post 发送json格式数据的时候加上 manager.requestSerializer = [AFJ... ......
- (void)postrequest{ afhttpsessionmanager *manager = [afhttpsessionmanager manager]; // >>>>>>>> post 发送json格式数据的时候加上 manager.requestserializer = [afjsonrequestserializer serializer]; manager.responseserializer = [afjsonresponseserializer serializer]; // <<<<<<<< [manager.requestserializer setvalue:@"token_string" forhttpheaderfield:@"authorization"]; nsstring *url = @""; nsdictionary *postdata = @{@"data1":@"one",@"data2":@"two"}; [manager post:url parameters:postdata progress:^(nsprogress * _nonnull uploadprogress) { } success:^(nsurlsessiondatatask * _nonnull task, id _nullable responseobject) { } failure:^(nsurlsessiondatatask * _nullable task, nserror * _nonnull error) { }]; }