AFN用Post发送Json数据

来源:互联网 发布:阿里云 自己安装系统 编辑:程序博客网 时间:2024/06/06 03:46
    NSDictionary * arr = @{                           @"userName":@"408131213@qq.com",                           @"passWord":@"111111",                           @"longitudes":@"changsha",                           @"phoneNo":@"iphone7",                           @"source":@"001"};   NSError *error;    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:arr options:NSJSONWritingPrettyPrinted error:&error];//此处data参数是我上面提到的key为"data"的数组    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];NSDictionary *dic=[NSDictionary dictionaryWithObject:jsonString forKey:@"reqBody"];    [YLAFNetWork POST:@"http://www.sfdhb.com/app/service" baseURL:nil params:dic success:^(NSURLSessionDataTask *task, id responseObject) {        NSLog(@"请求成功%@",responseObject);    } fail:^(NSURLSessionDataTask *task, NSError *error) {        NSLog(@"请求失败%@",error);;    }];
0 0
原创粉丝点击