Wednesday, October 28, 2026
HomeiOS Developmentios - Is there a strategy to arrange downsampling choice when fetching...

ios – Is there a strategy to arrange downsampling choice when fetching a picture with SDWebImage?

[ad_1]

That is how I set pictures to UIImageView from an internet url:

import UIKit

extension UIImageView {
    non-public var storage: Storageable {
        Assembler.shared.resolve(Storageable.self)!
    }

    non-public var imageDownloader: ImageDownloaderable {
        Assembler.shared.resolve(ImageDownloaderable.self)!
    }

    // MARK: - Inside

    func setImage(with url: URL) {
        downloadImage(with: url) { [weak self] picture in
            self?.picture = picture
        }
    }

    func downloadImage(with url: URL, completion: @escaping ImageHandler) {
        imageDownloader.setAuthorization(withToken: storage.bearerToken)
        sd_setImage(with: url, placeholderImage: nil,
                    choices: [.allowInvalidSSLCertificates, .avoidAutoSetImage]) { picture, _, _, _ in
            completion(picture)
        }
    }
}

How do I inform SDWebImage library to downsample a picture to particular dimension, to cut back reminiscence utilization. Is it attainable?

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments