Enabling Save for an NSDocument
-
11-09-2019 - |
Question
I am using an NSDocumentController subclass to do some custom stuff when I create my NSDocuments. The strange thing is that when the document is created, the Save option in the menu is disabled. The problem is that I use the save function to save something manually out from the document so it's decoupled from the main NSDocument saving procedure. Normally I use [self updateChangeCount: NSChangeDone] when I make changes in the document, but that doesn't seem to have any effect on enabling the Save menu item when the document is created.
I use [NSDocument saveToURL] when it's first created, so that might be what's disabling save afterwards. Is there a way for me to force it to be saveable again?
Solution
Have you explored using either of these?
NSDocument
- (BOOL)isDocumentEdited
NSDocumentController
- (BOOL)hasEditedDocuments
OTHER TIPS
I battled this for ages. In my case, the problem was that I hadn't linked the File's owner window outlet to my Window in the nib when I converted to a document-based app.