Skip navigation.
 
mlRe: Best way to get the window of an NSDocument?
FROM : mmalcolm crawford
DATE : Sat Apr 30 02:08:50 2005

On Apr 28, 2005, at 1:28 AM, Daniel Eggert wrote:

> It's a Model-View-Controller thing. NSDocument is your model, the 
> window is your view. The model should not have references to the 
> controller or view, but it is the controller that references the 
> model.
>

This doesn't really address the question.  Moreover, NSDocument is 
more a controller than a model (its actual role tends to be blurred 
-- in the context of the complete document architecture, though, it's 
typically a model-controller and NSWindowController a view controller).

>> NSDocument doesn't have a -window method to get the window for my 
>> document. I believe it's possible to have multiple windows for a 
>> single document but in this case, I'm putting a toolbar on my 
>> window during -windowControllerDidLoadNib: so the document isn't 
>> even finished opening yet. I'm using this
>> id myWindow = [self windowForSheet];
>>

If you're doing this in windowControllerDidLoadNib, you could ask the 
window controller for its window...

In general, if you're using an "out of the box" document-based 
application, then you can get the document's window from:

    [[[self windowControllers] objectAtIndex:0] window];

mmalc

Related mailsAuthorDate
mlBest way to get the window of an NSDocument? Marc Respass Apr 24, 19:59
mlRe: Best way to get the window of an NSDocument? Daniel Eggert Apr 28, 10:28
mlRe: Best way to get the window of an NSDocument? Marc Respass Apr 28, 21:15
mlRe: Best way to get the window of an NSDocument? mmalcolm crawford Apr 30, 02:08
mlRe: Best way to get the window of an NSDocument? Marc Respass Apr 30, 16:40