Instance Method

icon(forFile:)

Returns an image containing the icon for the specified file.

Declaration

func icon(forFile fullPath: String) -> NSImage

Parameters

fullPath

The full path to the file.

Return Value

The icon associated with the file.

Discussion

The returned image has an initial size of 32 pixels by 32 pixels.

It is safe to call this method from any thread of your app.

See Also

Managing Icons

func icon(forFileType: String) -> NSImage

Returns an image containing the icon for files of the specified type.

func icon(forFiles: [String]) -> NSImage?

Returns an image containing the icon for the specified files.

func setIcon(NSImage?, forFile: String, options: NSWorkspace.IconCreationOptions) -> Bool

Sets the icon for the file or directory at the specified path.

struct NSWorkspace.IconCreationOptions

These constants describe the NSWorkspaceIconCreationOptions values used by setIcon(_:forFile:options:). You can combine these using the C bitwise OR operator.