---
title: "preferredFilenameExtension(forType:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsworkspace/preferredfilenameextension(fortype:)"
---

# preferredFilenameExtension(forType:)

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

## Declaration

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

## Parameters

- `typeName`: A string containing the UTI.

## Return Value

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

## Discussion

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

## See Also

### Manipulating Uniform Type Identifier Information

- [type(ofFile:)](appkit/nsworkspace/type(offile:).md)
- [localizedDescription(forType:)](appkit/nsworkspace/localizeddescription(fortype:).md)
- [filenameExtension(_:isValidForType:)](appkit/nsworkspace/filenameextension(_:isvalidfortype:).md)
- [type(_:conformsToType:)](appkit/nsworkspace/type(_:conformstotype:).md)
