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

# currentDocument

The document object associated with the main window.

```
var currentDocument: NSDocument? { get }
```

## Discussion

The value of this property is `nil` if it is called when the app is not active. This can occur during processing of a drag-and-drop operation, for example, in an implementation of `readSelectionFromPasteboard:`. In such a case, send the following message instead from an `NSView` subclass associated with the document:

```objc
[[[self window] windowController] document];
```

## See Also

[`-  documentForFileName:`](/documentation/AppKit/NSDocumentController/documentForFileName:)

Returns the document object for the file in which the document data is stored.



---

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)