Re: pointer to window from NSDocController
Re: pointer to window from NSDocController
- Subject: Re: pointer to window from NSDocController
- From: "Carlos A. Weber" <email@hidden>
- Date: Thu, 26 Sep 2002 10:06:18 -1000
On Wednesday, Sep 25, 2002, at 06:37 Pacific/Honolulu, Steve Ivy wrote:
>
I'm working on displaying a custom sheet, and I need to get a pointer
>
to the document window form within my NSDocumentController subclass. I
>
can't find any API that will do that. Looking in IB, I see an outlet
>
on File's Owner called "window". I had, perhaps foolishly, assumed
>
that [MyDocController window] would do it, but instead I get a "does
>
not respond to 'window' " message in the compiler.
>
>
I feel like I'm missing something very elementary, but I'm not seeing
>
it. How to I get a pointer to my document's window?
This is a belated reply, but you haven't received any very helpful ones
so far (I am catching up with the list after being gone for a few days).
First, I have to ask why you are subclassing NSDocumentController
instead of NSWindowController. If you are starting from the Cocoa
Document-based application template in PB/IB, the File's Owner in your
nib is your NSDocument subclass, altho Apple's documentation recommends
that for anything but the simplest doc-based app the NSWindowController
subclass should be the File's Owner. The NSWindowController class has a
-window instance method, so it is indeed trivial to write [self window]
in any method you write on your NSWindowController subclass to message
your window.
If it really is your NSDocumentController subclass that needs to send a
message to a window (again, I don't see how opening sheets on windows
falls within the purview of the NSDocumentController, but then I don't
know anything about your app), it seems to me you could start from
NSDocumentController's -currentDocument method to get the current
document, use NSDocument's -windowControllers method to get an array of
window controllers for the doc, then (if your document can have more
than one window associated with it) walk the array until you get the
NSWindowController with the appropriate subclass (you could use
-isMemberOfClass:), then send that NSWindowController instance a
-window message to get the window. (The fact that this is so convoluted
suggests that there should be a better way. I outlined my idea for that
in the paragraph preceding.)
Hope it helps.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.