I\'m trying to inject data/response from URLRequest into another URLRequest in my cache.
This is just a sample code. It\'s re
I resolved this problem by replacing first guard inside dataTask completionHandler with:
guard error == nil else {
print(error)
if let cr = session.configuration.urlCache?.cachedResponse(for: urlRequest){
let image = UIImage(data: cr.data)
DispatchQueue.main.async {
self?.imageView.image = image
}
}
return
}
If request fails, it will take cached response for that request