FROM : Marc Respass
DATE : Sat Apr 30 16:40:01 2005
On Apr 29, 2005, at 8:08 PM, mmalcolm crawford wrote:
>
> 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];
>
Thanks for the response. My real question is really if using
windowForSheet is wrong or a hack and I think it's at least not best.
According to the docs, -windowForSheet "returns the window of the
first window controller" or [NSApp mainWindow] but since I'm in
windowControllerDidLoadNib, I figured it was safe. I'll change it to
ask the first window controller for its window. That does seem
better. Thanks again for the help.
Marc
DATE : Sat Apr 30 16:40:01 2005
On Apr 29, 2005, at 8:08 PM, mmalcolm crawford wrote:
>
> 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];
>
Thanks for the response. My real question is really if using
windowForSheet is wrong or a hack and I think it's at least not best.
According to the docs, -windowForSheet "returns the window of the
first window controller" or [NSApp mainWindow] but since I'm in
windowControllerDidLoadNib, I figured it was safe. I'll change it to
ask the first window controller for its window. That does seem
better. Thanks again for the help.
Marc
| Related mails | Author | Date |
|---|---|---|
| Marc Respass | Apr 24, 19:59 | |
| Daniel Eggert | Apr 28, 10:28 | |
| Marc Respass | Apr 28, 21:15 | |
| mmalcolm crawford | Apr 30, 02:08 | |
| Marc Respass | Apr 30, 16:40 |






Cocoa mail archive

