<!--
{
  "availability" : [
    "macOS: 10.0.0 - 12.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSWorkspace/icon(forFileType:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSWorkspace(im)iconForFileType:"
  },
  "title" : "icon(forFileType:)"
}
-->

# icon(forFileType:)

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

```
func icon(forFileType fileType: String) -> NSImage
```

## Parameters

`fileType`

The file type, which may be either a filename extension, an encoded HFS file type, or a universal type identifier (UTI).

## Return Value

The icon associated with files of the given type.

## Discussion

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

You can safely call this method from any thread of your app.

## See Also

[`-  iconForFiles:`](/documentation/AppKit/NSWorkspace/icon(forFiles:))

Returns an image containing the icon for the specified files.

[`-  iconForFile:`](/documentation/AppKit/NSWorkspace/icon(forFile:))

Returns an image containing the icon for the specified file.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)