iosswifthaneke

Haneke in Swift: Eagerly loading images


Is there a way to load an image from an URL and write it directly to the disk cache (without presenting them to an UIImageView), so that I can emulate eager loading?

Problems emanate from the need to present 100+ images 4MB each (can't resize them any lower); so we decided to just download all of them into the disk cache, displaying a progress bar to the user, and presenting them after all are in the disk cache.

Any solution that uses Hanake to emulate eager loading will do.


Solution

  • Could you download and save it in a NSCache so do something like

    let cache = NSCache()
    cache.setObject(image, forKey: theURLYouDownloadedFrom)