Search code examples
objective-ccocoamodal-dialognsdocumentnssavepanel

Saving a cocoa doc from outside NSDocument class


During my app workflow there is a moment when a new modal NSWindow is initialized from a nib. This window should have a save document button. Which is the recommended approach:

  1. Via a new NSSavePanel to the newly instantiated modal window and customizing the entire save flow here ?
  2. Using the main NSDocument class that receives save message from the button in the above window ? If so, how to save the document ?
  3. Any other scenario ?

Solution

  • For those interested, I have solved this creating a singleton class with accesors that allows using "global"-like variables, thus calling methods and sending messages from the newly instantiated NSWindowController is now a breeze. Todo: look into possible using KVC for this.