---
title: "documentClass(forType:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsdocumentcontroller/documentclass(fortype:)"
---

# documentClass(forType:)

Returns the NSDocument subclass associated with a given document type.

## Declaration

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

## Parameters

- `typeName`: The name of a document type, specified by CFBundleTypeName in the application’s Info.plist file. The document type must be one the receiver can read.

## Return Value

Return Value Returns the NSDocument subclass associated with documentTypeName. If the class cannot be found, returns nil.

## See Also

### Managing Document Types

- [documentClassNames](appkit/nsdocumentcontroller/documentclassnames.md)
- [defaultType](appkit/nsdocumentcontroller/defaulttype.md)
- [displayName(forType:)](appkit/nsdocumentcontroller/displayname(fortype:).md)
- [typeForContents(of:)](appkit/nsdocumentcontroller/typeforcontents(of:).md)
