• 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: NSWindowController window returns nil
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSWindowController window returns nil


  • Subject: Re: NSWindowController window returns nil
  • From: email@hidden
  • Date: Wed, 7 Jul 2010 20:04:15 -0600

Thanks for th input Matt.

I found that I had not connected the window outlet in Files Owner to the window in the nib. Upon doing so all works as I expected.

As an FYI everything else works as I expect ... the delegate methods are called and the instance vars are good to go. One slight change, I made my content view an instance var so the code now looks like this:

- (id) initWithWindowNibName:(NSString*)windowNibName andBFileName: (BFilename*)bfilename
{
self = [super initWithWindowNibName:windowNibName];
if (self != nil)
{
[self retain];
m_panel = [self window];
m_design = [m_panel contentView];
m_design->m_BFilename = bfilename;
[m_panel setDelegate:self];
[m_panel makeKeyAndOrderFront:self];
}
return self;
}


- (void)windowWillClose:(NSNotification *)notification {

	[self release];
}


Thanks to all for helping me keep my direction true!

-koko

On Jul 7, 2010, at 6:47 PM, Matt Neuburg wrote:

On Wed, 7 Jul 2010 16:54:04 -0600, email@hidden said:
- (id) initWithWindowNibName:(NSString*)windowNibName andBFileName:
(BFilename*)bfilename
{
self = [super initWithWindowNibName:windowNibName];
if (self != nil)
{
m_panel = [self window];
Design *cv = [m_panel contentView];
cv->m_BFilename = bfilename;
[m_panel setDelegate:self];
[m_panel makeKeyAndOrderFront:self];
}
return self;
}



Im the above, the call [self window] returns nil. This does not seem
correct. Can some one help me?

You're speaking of the window too early. This is just the init; the nib
hasn't yet loaded and set up the connections. This is why you are given
windowDidLoad, so you know when the window *is* ready.


I would go even further and say that most of what you're doing here should
not be done in an init. Set instance variables and that's all. And set them
directly; don't pass through a setter. Remember, the instance (self) is not
ready until you have *returned* from the init. m.


--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings





_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: NSWindowController window returns nil (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: Programmatically highlighting an NSMenuItem
  • Next by Date: Re: static analyzer
  • Previous by thread: Re: NSWindowController window returns nil
  • Next by thread: Programmatically closing a submenu (NSMenu)
  • Index(es):
    • Date
    • Thread