国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > iOS > 正文

IOS用AFN發送字符串形式的Json數據給服務器實例

2019-10-21 18:46:59
字體:
來源:轉載
供稿:網友

每個人遇到后臺的需求不一樣,我只能寫出自己目前遇到的需求和做法,我的后臺是需要一個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失敗");  }];

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。


注:相關教程知識閱讀請移步到IOS開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 石阡县| 济阳县| 诏安县| 宣恩县| 水城县| 江山市| 磐石市| 丰顺县| 莱芜市| 阳谷县| 上犹县| 临洮县| 邯郸县| 万载县| 台南市| 合作市| 崇阳县| 祁阳县| 阿克陶县| 福泉市| 红桥区| 洞头县| 富宁县| 赞皇县| 遂溪县| 江永县| 田林县| 惠州市| 长沙市| 滁州市| 望城县| 苏尼特右旗| 油尖旺区| 文山县| 兴安县| 扬中市| 江西省| 合川市| 临澧县| 年辖:市辖区| 金门县|