Note that there are some explanatory texts on larger screens.

plurals
  1. POReference to subclassed NSWindowController returns its document - is this correct?
    text
    copied!<p>I am new to document-based applications and hence I may have missed something fundamental. I have written a document based application which uses a subclassed NSWindowController for the interface and a subclassed NSDocument for the model. Per the documentation I initialise the windowController in makeWindowControllers and load its xib. In interface builder, the xib has my windowController subclass set as File's Owner. Among the views in the window, I have a subclass of NSOutlineView and the NSOutlineView datasource and delegate are also refenced in the nib and connected to the windowController via IBOutlets.</p> <p>According to the documentation, I should be able to access the document from the OutlineView datasource via [windowController document]. However, referencing the windowController (via IBOutlet) from the OutlineView datasource gives me the document instead!</p> <p>This has lead to some rather ugly code in the OutlineView datasoure (which is a subclass of NSObject in the windowController's xib) to get hold of the document, eg:</p> <pre><code>-(MyDocument *)myDocument { MyDocument *theDocument = (MyDocument *)myWindowController; return theDocument; } </code></pre> <p>Where the IBOutlet in the header file references myWindowController as:</p> <pre><code>IBOutlet MyWindowController *myWindowController </code></pre> <p>In brief - why does an IBOutlet connected to the windowController get me the document directly instead in this situation? The above code works but seems as if it shouldn't.</p> <p>Edit: clarification</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload