generateRepresentations(for:update:)
Generates various thumbnail representations for a file and calls the update handler for each thumbnail representation.
Declaration
func generateRepresentations(for request: QLThumbnailGenerator.Request, update updateHandler: ((QLThumbnailRepresentation?, QLThumbnailRepresentation.RepresentationType, (any Error)?) -> Void)? = nil)Parameters
- request:
The request that contains information about the thumbnail that you want to create.
- updateHandler:
The handler to call successively for each requested representation of a thumbnail. QuickLookThumbnailing calls the
updateHandlerin order of lower quality to higher quality thumbnail types. If a better quality thumbnail becomes available before a lower quality one, the framework may skip the call to theupdateHandlerfor the lower quality thumbnail. You can rely on QuickLookThumbnailing to call theupdateHandlerat least once by the time it finishes the creation of thumbnails with either the best requested thumbnail, or an error object.The handler takes the following parameters:
thumbnailA thumbnail that is successfully generated or
nilifQLThumbnailGeneratoris unable to generate a thumbnail.typeThe type of the generated thumbnail representation.
errorAn error object that indicates why the thumbnail generation failed, or
nilif the thumbnail generation succeeded.
Mentioned in
Discussion
Use this method if you want to create a file icon or low-quality thumbnail quickly, and replace it with a higher quality thumbnail once it becomes available.