I have a prototype project of url based documents, where I cache document info to user defaults. User actions tally the change count which I'd like to autosave - once I figure out how, so an explicit close triggers the standard dialog to save first.
Choosing not to save, the window closes - first calling the window's delegate, method - windowShouldClose, as expected. Choosing save, triggers a call to the document's method
override func save(to url: URL, ofType typeName: String, for saveOperation: NSSaveOperationType, completionHandler: @escaping (Error?) -> Void) {
do {
try self.write(to: url, ofType: typeName)
Swift.print("save(to: \(url.absoluteString) ofType: \(typeName)) ")
} catch let error {
NSApp.presentError(error)
}
}
which runs to completion - I get the debug output, ok but I suspect something's wrong as the window delegate method isn't called; a 2nd try to close the window closes without incident.
I'm confused what state is not right that the change clearing didn't reset, allow the doc to close its window after saving? Btw I do not update change count.