Mac Developer Library

Developer

AppKit Framework Reference NSDockTile Class Reference

Options
Deployment Target:

On This Page
Language:

NSDockTile

Inheritance


Conforms To


Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.5 and later.

The NSDockTile class lets you customize the visual representation for your application’s miniaturized windows and application icon as they appear in the Dock. You do not create Dock tile objects explicitly in your application. Instead, you retrieve the Dock tile for an existing window or for the application by calling that object’s dockTile method.

Typically, you do not subclass the NSDockTile class. Instead, you use the methods of the class to make the following customizations:

  • Badge the tile with a custom string.

  • Remove or show the application icon badge.

  • Draw the tile content yourself.

If you decide to draw the tile content yourself, you must provide a custom content view to handle the drawing.

Application Dock Tiles

An application Dock tile defaults to display the application’s applicationIconImage.

The application Dock tile never shows a smaller application icon badge.

Whether using the default or custom view, the application Dock tile may be badged with a short custom string.

Window Dock Tiles

A window Dock tile defaults to display a miniaturized version of the windows contents with a badge derived from the application Dock icon, including any customized application Dock icon. The default window Dock tile image may not be badged with a custom string.

A window Dock tile can use a custom view to draw the Dock icon. If a custom view is used, no application badge will be added, but the text label will be overlaid on top of the icon.

  • Sets the view to use for drawing the dock tile contents.

    Declaration

    Swift

    var contentView: NSView?

    Objective-C

    @property(strong) NSView *contentView

    Parameters

    view

    The view to use for drawing the tile. This view may contain additional subviews.

    Discussion

    The view you specify should be height and width resizable.

    Cocoa does not automatically redraw the contents of your dock tile. Instead, your application must explicitly send display messages to the dock tile object whenever the contents of your view change and need to be redrawn. Your dock tile view is responsible for drawing the entire contents of the dock tile. Your view does not need to draw the application or custom string badges.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Returns the view used to draw the dock tile contents.

    Declaration

    Swift

    var contentView: NSView?

    Objective-C

    @property(strong) NSView *contentView

    Return Value

    The view used to draw the tile.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Returns the size of the tile.

    Declaration

    Swift

    var size: NSSize { get }

    Objective-C

    @property(readonly) NSSize size

    Return Value

    The size of the tile, measured in screen coordinates.

    Discussion

    The size returned by this method corresponds to the size of the backing store in the dock, which may be bigger than the actual tile displayed on the screen.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Returns the object represented by the dock tile.

    Declaration

    Swift

    unowned(unsafe) var owner: AnyObject { get }

    Objective-C

    @property(readonly, assign) id owner

    Return Value

    The object represented by the dock tile. This is either the NSApplication object or one of your application’s NSWindow objects.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Sets whether the tile should be badged with the application’s icon.

    Declaration

    Swift

    var showsApplicationBadge: Bool

    Objective-C

    @property BOOL showsApplicationBadge

    Parameters

    flag

    YEStrue to show the application icon; otherwise, NOfalse to hide it.

    Discussion

    Miniaturized windows include the application badge by default to convey the associated application to the user. In OS X v10.5 and later, application tiles do not support the application badge. A miniaturized window with a custom view does not draw the application badge.

    The application icon is positioned automatically in the tile by the NSDockTile object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Returns a Boolean value indicating whether the tile is badged with the application’s icon.

    Declaration

    Swift

    var showsApplicationBadge: Bool

    Objective-C

    @property BOOL showsApplicationBadge

    Return Value

    YEStrue if the tile is badged; otherwise, NOfalse. Returns YEStrue by default.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Sets the string to be displayed in the tile’s badging area.

    Declaration

    Swift

    var badgeLabel: String?

    Objective-C

    @property(copy) NSString *badgeLabel

    Parameters

    string

    The localized string to display. This string can contain a count value or other badging information. To clear the badge string, specify an empty string (@"") or nil.

    Discussion

    The appearance of the badge area is system defined.

    Window dock tiles only display a badge label when there is a custom view associated with the dock tile.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Returns the tile’s current badge label.

    Declaration

    Swift

    var badgeLabel: String?

    Objective-C

    @property(copy) NSString *badgeLabel

    Return Value

    The localized string to be displayed in the tile’s badging area. This string may be empty or nil.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Redraws the dock tile’s content.

    Declaration

    Swift

    func display()

    Objective-C

    - (void)display

    Discussion

    If a custom content view is provided, Cocoa calls the drawRect: method of that view (and its subviews) to draw the tile’s content.

    You can call this method to force the redrawing of the dock tile contents. You might do this if the contents of the underlying application or window change in a way that would require a refreshing of the tile. Some types of system activity, such as resizing the dock, may trigger automatic redraws of the tile. In most cases, however, your application is responsible for triggering redraws.

    Cocoa does not automatically redraw the contents of your dock tile. Instead, your application must explicitly send display messages to the dock tile object whenever the contents of your view change and need to be redrawn.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • The version of the AppKit framework containing support for dock tile plug-ins.

    Declaration

    Swift

    var NSAppKitVersionNumberWithDockTilePlugInSupport: Double { get }

    Objective-C

    #define NSAppKitVersionNumberWithDockTilePlugInSupport 1001.0

    Constants

    • NSAppKitVersionNumberWithDockTilePlugInSupport

      NSAppKitVersionNumberWithDockTilePlugInSupport

      The specific version of the AppKit framework that introduced support for dock tile plug-ins.. Developers should not need to use this constant unless they are writing applications for OS X v10.5 and earlier.

      Available in OS X v10.6 and later.