AFNetworking 何以POST壹个JSON数据到效力动器

2018-08-23 -

  代码如次:

  AFHTTPRequestOperationManager *manager=[AFHTTPRequestOperationManager manager];

  //音皓前往的结实是json典型

  manager.responseSerializer=[AFJSONResponseSerializer serializer];

  //音皓央寻求的数据是json典型

  manager.requestSerializer=[AFJSONRequestSerializer serializer];

  //假设报接受典型不不符请提交流动不符text/html或佩的

  manager.responseSerializer.acceptableContentTypes=[NSSet setWithObject:@"text/html"];

  //传入的参数

  NSDictionary *parameters=@{@"1":@"XXXX",@"2":@"XXXX",@"3":@"XXXXX"};

  //你的接口地址

  NSString *url=@"http://xxxxx";

  //发递送央寻求

  [manager POST:url parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {

  NSLog(@"JSON: %@", responseObject);

  } failure:^(AFHTTPRequestOperation *operation, NSError *error) {

  NSLog(@"Error: %@", error);

  }];

  伸荐去看

  http://my.oschina.net/gexun/blog/316408

  文字到来源:https://zhidao.baidu.com/question/1367307618471618779.html