1

I'm trying to make a Quick Look generator. My understanding is that you can provide QLPreviewRequestSetDataRepresentation any type of data that can be understood by Quick Look out-of-the-box. I'd like to provide image data (kUTTypeImage).

Here's the simplest thing I can get to fail: load an input image and then immediately return it to QLPreviewRequestSetDataRepresentation.

(Obviously, in my real application I would do some custom transformations to the image before returning it, but even this simplified example seems to fail.)

NSImage *inputImage = [[NSImage alloc] initWithContentsOfURL:inputImageURL];
QLPreviewRequestSetDataRepresentation(preview,
                                      (__bridge CFDataRef)([inputImage TIFFRepresentation]),
                                      kUTTypeImage,
                                      nil);

This doesn't work, even though the documentation gives every indication that it should. The Quick Look generator just crashes and falls back to the default display.

I know the NSImage is being properly read from the Quick Look bundle.

I can set the data to HTML just fine, and even include the image as an attachment and render as HTML, but that's a hacky solution.

I've uploaded the full generator file as a Gist here.

Wil Gieseler
  • 1,893
  • 1
  • 17
  • 18
  • Have you tried setting the type to the UTI of the specific image format that you are providing? (in this case, TIFF) – Thomas Deniau Jul 14 '14 at 19:39
  • Yep, I tried setting it to "public.tiff". – Wil Gieseler Jul 14 '14 at 22:54
  • Could you attach the syslog, crash log, etc.? – Thomas Deniau Jul 15 '14 at 15:47
  • I’m having the same issue, look at [my question](http://stackoverflow.com/questions/24526385/why-does-qlpreviewrequestsetdatarepresentation-on-mavericks-return-error-cgima). My code used to work but isn’t working anymore, since Mavericks, I guess. – wdyp Jul 26 '14 at 17:16

0 Answers0