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

# preferredFilenameExtension(forType:)

Returns the preferred filename extension for the specified Uniform Type Identifier (UTI).

```
func preferredFilenameExtension(forType typeName: String) -> String?
```

## Parameters

`typeName`

A string containing the UTI.

## Return Value

The appropriate filename extension for `typeName`, or `nil` if no extension could be determined.

## Discussion

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

---

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)