Same over here.
I added a few print() statements to the fetchImage function to see if I could get a slight idea of what was going on.
func fetchImage(url: URL, completion: @escaping (UIImage?) -> Void) {
let task = URLSession.shared.dataTask(with: url) {
(data, response, error) in
if let data = data {
print("data: (data)")
if let image = UIImage(data: data) {
completion(image)
} else {
print("Could not fetch image")
}
} else {
print("Failed to fetch data")
completion(nil)
}
}
task.resume()
}
Here is my consul output:
data: 69 bytes
Could not fetch image
As far as my understanding goes right now, I assume the data for the image is retrieved but when looking for the image with the data it can't access the images folder so it can't find the requested data?