【发布时间】:2015-03-28 20:34:27
【问题描述】:
我有一个 NSURLSession 调用dataTaskWithRequest 以发送 POST 请求。我修改了我找到的示例here。
var task = session.dataTaskWithRequest(request, completionHandler: {data, response, error -> Void in
println("Response: \(response)")
// Other stuff goes here
})
我似乎无法从响应中获取标题。我知道我想要的 cookie 在标题中的某个位置,因为当我在上面的代码中打印出响应时,它会显示我想要的 cookie。但是我该如何正确地取出 cookie?
我尝试解析 JSON,但我不知道如何将 NSURLResponse 转换为 NSData,如下所示:
NSJSONSerialization.JSONObjectWithData(ResponseData, options: .MutableLeaves, error: &err)
【问题讨论】: