---
title: "setDocumentEdited(_:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nswindowcontroller/setdocumentedited(_:)"
---

# setDocumentEdited(_:)

Sets the document edited flag for the window controller.

## Declaration

```swift
func setDocumentEdited(_ dirtyFlag: Bool)
```

## Parameters

- `dirtyFlag`: doc://com.apple.documentation/documentation/Swift/true if the document has been edited since its last save, doc://com.apple.documentation/documentation/Swift/false if it hasn’t.

## Discussion

Discussion The window controller uses this flag to control whether its associated window shows up as dirty. You should not call this method directly for window controllers with an associated document; the document calls this method on its window controllers as needed.

## See Also

### Accessing the Document

- [document](appkit/nswindowcontroller/document.md)
