1

I have a rather large image, which I display inside NSImageView. Once I do it the first time, every next usage of said image is very fast. Either when re-using the NSImageView it was assigned to or assigning it to a new NSImageView. This is apparently due to the fact that NSImage keeps cache of the representation it used for displaying said image the first time. The problem is with displaying it the first time though. Even on a fast hardware there is an unacceptably long delay before the image eventually appears. What I am looking for is a way to pre-cache the image representation before I display it the first time. Any suggestions?

FWIW, I use Obj-C for OS X/macOS but I believe it shouldn't make any difference and Swift techniques should be applicable too.

silverdr
  • 1,978
  • 2
  • 22
  • 27
  • The `valid` property may help: *... this method loads the data and expands it as needed...*. – Gerd K Jun 03 '19 at 21:52
  • @GerdK - I use isValid() (the getter for the property in question) before displaying the image so this seems not to help. I also use `initWithContentsOfFile` rather than `initByReferencingFile` so that it's not lazy-loaded. – silverdr Jun 03 '19 at 23:40

0 Answers0