I am trying to use af_setImage to add images to UICollectionViewCell. Default timeoutIntervalForRequest is 60 seconds, but I should not wait the user more than 15 seconds. How can I set the custom timeoutIntervalForRequest for af_setImage? I tried below solutions, but they did not work.
let downloader = UIImageView.af_sharedImageDownloader
let configuration = downloader.sessionManager.session.configuration
configuration.timeoutIntervalForResource = 15
configuration.timeoutIntervalForRequest = 15
af_setImage(withURL: url, completion: { (response) in
// do stuff
})
Tried bottom solution to but didn't work
af_imageDownloader?.sessionManager.session.configuration.timeoutIntervalForResource = 15
af_imageDownloader?.sessionManager.session.configuration.timeoutIntervalForRequest = 15
//tried this instead of af_setImage, this is not working too.
af_imageDownloader?.sessionManager.request(URLRequest(url: url))
.responseJSON {
response in
switch (response.result) {
case .success:
// success
break
case .failure(let error):
// fail
break
}
}