The NSUndoManager for your application knows when unsaved edits have occurred. Also, the window is automatically marked as edited. But what if you have written an application and are not registering your changes with the undo manager?
NSDocument keeps track of how many changes have been made. It has a method for this purpose:
func updateChangeCount(change: NSDocumentChangeType)
The NSDocumentChangeType can be one of the following: ChangeDone, ChangeUndone, or ChangeCleared. ChangeDone increments the change count, ChangeUndone decrements the change count, and ChangeCleared sets the change count to 0. The window is ...