医生手术后默哀,兄弟之生死同盟下载,购得乐
每个人遇到后台的需求不一样,我只能写出自己目前遇到的需求和做法,我的后台是需要一个json的key,对应一个字符串类型的字典,后台要求的是带双引号和冒号的字典,所以就拼接了一下
afhttpsessionmanager *manager = [afhttpsessionmanager manager]; // 发送post请求 // manager.responseserializer = [afjsonresponseserializer serializer]; manager.responseserializer = [afjsonresponseserializer serializer]; manager.responseserializer.acceptablecontenttypes = [nsset setwithobject:@"text/html"]; // manager.requestserializer=[afhttprequestserializer serializer]; nsdictionary *json = [nsdictionary dictionary]; nsstring *str = [nsstring stringwithformat:@"{\"city\":\"%@\",\"country\":\"%@\",\"headimgurl\":\"%@\",\"language\":\"%@\",\"openid\":\"%@\",\"province\":\"%@\",\"sex\":%@,\"unionid\":\"%@\",\"username\":\"%@\"}",self.userinfodict[@"city"],self.userinfodict[@"country"],self.userinfodict[@"headimgurl"],self.userinfodict[@"language"],self.userinfodict[@"openid"],self.userinfodict[@"province"],self.userinfodict[@"sex"],self.userinfodict[@"unionid"],self.userinfodict[@"nickname"]]; json = @{ // @"city":self.userinfodict[@"city"], // @"country":self.userinfodict[@"country"], // @"headimgurl":self.userinfodict[@"headimgurl"], // @"language":self.userinfodict[@"language"], // @"openid":self.userinfodict[@"openid"], // @"province":self.userinfodict[@"province"], // @"sex":self.userinfodict[@"sex"], // @"unionid":self.userinfodict[@"unionid"], // @"username":self.userinfodict[@"nickname"], @"json":str, // @"json":@"json" }; nslog(@"post调试%@",json); nsstring *urlstr = @"http://10.62.16.247:8080/loginservlet.bmh"; [manager post:urlstr parameters:json progress:^(nsprogress * _nonnull uploadprogress) { } success:^(nsurlsessiondatatask * _nonnull task, id _nullable responseobject) { nsstring *str = responseobject; nslog(@"post回调====%@",str); nslog(@"post成功"); } failure:^(nsurlsessiondatatask * _nullable task, nserror * _nonnull error) { nslog(@"post失败"); }];
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
iOS 使用UITextField自定义搜索框 实现用户输入完之后“实时搜索”功能
网友评论