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

# documentClass(forType:)

Returns the `NSDocument` subclass associated with a given document type.

```
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

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

---

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)