Mac Developer Library

Developer

Quick Look Framework Reference for Mac QLPreviewItem Protocol Reference

Options
Deployment Target:

On This Page
Language:

QLPreviewItem

The QLPreviewItem protocol defines properties you implement to make your application’s content visible in a QuickLook preview (QLPreviewController in iOS or QLPreviewPanel in OS X).

The methods in this protocol are also declared as a category on the NSURL class. As a result, you can use NSURL objects directly as preview items—provided that you want to use the default titles of those items. A default title is the last path component of an item’s URL. If you want to supply your own preview item titles, create your own preview item objects that adopt this protocol.

  • The URL of the item to preview.

    Declaration

    Swift

    var previewItemURL: NSURL! { get }

    Objective-C

    @property(readonly) NSURL *previewItemURL

    Discussion

    This property is used by a Quick Look preview controller to get an item’s URL. In typical use, you would implement a getter method in your preview item class to provide this value.

    The value of this property must be a file-type URL.

    If the item is not available for preview, this property’s getter method should return nil. In this case, the Quick Look preview controller displays a “loading” view.

    Availability

    Available in OS X v10.6 and later.

  • The title to display for the preview item.

    Declaration

    Swift

    optional var previewItemTitle: String! { get }

    Objective-C

    @property(readonly) NSString *previewItemTitle

    Discussion

    If you do not implement a getter method for this property, or if your method returns nil, QuickLook examines the URL or content of the item being previewed to determine an appropriate title for display to the user. Return a non-nil value for this property to provide a custom title.

    Availability

    Available in OS X v10.6 and later.

  • The display state for the preview item. This property is optional.

    Declaration

    Swift

    optional var previewItemDisplayState: AnyObject! { get }

    Objective-C

    @property(readonly) id previewItemDisplayState

    Discussion

    The display state is an opaque object used by the preview panel. You typically use the QLPreviewPanel method displayState to retrieve the display state which you save for later use in the preview item. This way you can preserve the display state when the panel moves from/to an other controller.

    Availability

    Available in OS X v10.6 and later.

    See Also

    displayState (QLPreviewPanel)