2
tl; dr; 我要打印生成(通过Alamofire)请求(或至少请求正文)使用Swift如何在Swift中打印请求NSMutableURLRequest
我收到NSMutableURLRequest
对象。
我曾尝试:
Alamofire.request(.POST, URL, parameters: params)
.responseJSON{ request, response, JSON, error in
println(request)
但我收到(调试器输出):
(lldb) p println(request)
<NSMutableURLRequest: 0x7faac257f520> { URL: http://apphb.com/api/x }
也许description
?
(lldb) p println(request.description)
<NSMutableURLRequest: 0x7faac257f520> { URL: http://apphb.com/api/x}
HTTPBody
? (...
下面==输出手动缩短是我)
(lldb) p println(request.HTTPBody!)
<416e7377 65727325 ... 38323833>
Ecoding - 没有那么糟糕,但没有格式化
(lldb) p println(NSString(data: request.HTTPBody!, encoding:NSUTF8StringEncoding)!)
Answers%5B%5D%5BAnswerId%5D=65&An...
但我要得到充分的要求和身体JSON(使用SwiftyJSON?) - 如何实现它?
我对Alamofire并不熟悉,但我会打赌,响应和JSON都在'response'和'JSON'变量中,而不是'request'中。 'println(response)'是什么打印的? –
最后一行错误 - 我需要请求(响应和响应JSON打印正常) – abrasadera