亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

IOS用AFN發(fā)送字符串形式的Json數(shù)據(jù)給服務(wù)器實例

 更新時間:2017年04月17日 15:24:52   作者:_Dave  
本篇文章主要介紹了IOS用AFN發(fā)送字符串形式的Json數(shù)據(jù)給服務(wù)器實例,具有一定的參考價值,感興趣的小伙伴們可以參考一下。

每個人遇到后臺的需求不一樣,我只能寫出自己目前遇到的需求和做法,我的后臺是需要一個Json的key,對應(yīng)一個字符串類型的字典,后臺要求的是帶雙引號和冒號的字典,所以就拼接了一下

AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
  // 發(fā)送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調(diào)試%@",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回調(diào)====%@",str);
    NSLog(@"post成功");
  } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
    NSLog(@"post失敗");
  }];

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論