• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to get an NSWindow from an NSDocument?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >How to get an NSWindow from an NSDocument? (From: "Theodore H. Smith" <email@hidden>)

  • Prev by Date: Re: "Reveal Drawer" button in title bars
  • Next by Date: core data and dictionary
  • Previous by thread: How to get an NSWindow from an NSDocument?
  • Next by thread: Re: How to get an NSWindow from an NSDocument?
  • Index(es):
    • Date
    • Thread