gpt4 book ai didi

ios - downloadTaskWithURL 如何获取实际数据

转载 作者:行者123 更新时间:2023-11-28 08:52:22 24 4
gpt4 key购买 nike

<分区>

我正在尝试下载图片。

这是图片链接

https://www.google.it/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png

我所做的是:

   let url = NSURL(string: "https://www.google.it/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png")
let session = NSURLSession.sharedSession()
let task = session.downloadTaskWithURL(url!, completionHandler: {(url, response, error) in
if let error = error {
print("error = \(error)")
}

if let response = response {
print("response = \(response)")
}

})
task.resume()

真的我有一个回应,我可以在日志中看到它如下:

response = <NSHTTPURLResponse: 0x7fc1a1427060> { URL: https://www.google.it/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png } { status code: 200, headers {
"Cache-Control" = "private, max-age=31536000";
"Content-Length" = 13504;
"Content-Type" = "image/png";
Date = "Mon, 23 Nov 2015 23:57:55 GMT";
Expires = "Mon, 23 Nov 2015 23:57:55 GMT";
"Last-Modified" = "Fri, 04 Sep 2015 22:33:08 GMT";
Server = sffe;
"alt-svc" = "quic=\"www.google.com:443\"; p=\"1\"; ma=600,quic=\":443\"; p=\"1\"; ma=600";
"alternate-protocol" = "443:quic,p=1";
"x-content-type-options" = nosniff;
"x-xss-protection" = "1; mode=block";
} }

我的问题是在获取实际图像的响应中没有数据。我曾经调用 dataTaskWithRequest 并且它的 clouser 有这样的数据:

session.dataTaskWithRequest(request, completionHandler: {(data, response, error)

但是我在这里没有找到数据,请问我哪里错了?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com