Re: How to get an NSWindow from an NSDocument?
Re: How to get an NSWindow from an NSDocument?
- Subject: Re: How to get an NSWindow from an NSDocument?
- From: John Timmer <email@hidden>
- Date: Mon, 23 May 2005 13:05:53 -0400
I don't know what you were doing wrong, but there's an easier way of
handling this. NSDocument has a method you can override in your subclass
called:
- (void)windowControllerDidLoadNib:(NSWindowController *)windowController
Just make a class variable for the window controller and retain it when this
method is called (which happens right after NIB loading). As you note in
your own code, the controller responds to "window" by returning the window
reference you want.
JT
> I have a document based Cocoa app.
>
> I want to do stuff to it's window, like set the title of the window
> when I open a file. However, I can't figure out how to get an NSWindow
> from the NSDocument. I tried this:
>
>
> - (NSWindow*) window { // from a subclass of NSDocument
> NSArray* a = [self windowControllers];
> NSWindowController* wc = [a objectAtIndex:0];
> NSWindow* w = [wc window];
> return w;
> }
>
> But I get an error that the NSArray actually contains no window
> controllers. What was I doing wrong?
_______________________________________________
This mind intentionally left blank
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden