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

# setDocumentEdited(_:)

Sets the document edited flag for the window controller.

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

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.

---

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)