---
title: currentDocument
framework: appkit
role: symbol
role_heading: Instance Property
path: appkit/nsdocumentcontroller/currentdocument
---

# currentDocument

The document object associated with the main window.

## Declaration

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

## Discussion

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: [[[self window] windowController] document];

## See Also

### Managing Documents

- [documents](appkit/nsdocumentcontroller/documents.md)
- [addDocument(_:)](appkit/nsdocumentcontroller/adddocument(_:).md)
- [document(for:)](appkit/nsdocumentcontroller/document(for:)-a5yd.md)
- [hasEditedDocuments](appkit/nsdocumentcontroller/hasediteddocuments.md)
- [removeDocument(_:)](appkit/nsdocumentcontroller/removedocument(_:).md)
