Re: -[NSWindowController window] fails
Re: -[NSWindowController window] fails
- Subject: Re: -[NSWindowController window] fails
- From: j o a r <email@hidden>
- Date: Fri, 28 Nov 2008 09:31:43 -0800
On Nov 28, 2008, at 2:06 AM, Alexander Shmelev wrote:
I have NSWindowController which loads nib with following code:
- (id) init
{
if (![super initWithWindowNibName:@"Dialog"])
return nil;
[self window];
}
I use [self window] to force nib load. This code perfectly works on
Leopard(Intel), but [self window] fails if I run it on Tiger(PPC) -
code after [self window] is not executed.
You don't have any code after [self window], so that's to be
expected... ;-)
Jokes aside, you need to "return self;" at the end of the method. You
should have a compiler warning / error about that.
I also agree with Kyle that calling [self window] in init is probably
not what you want to do. It might not even be "safe". In general you
should be very careful about calling methods on self from your
initializer. Consider this as something you need to be almost as
careful and respectful around as thread safety. Before you have
returned from your initializer your object is not to be considered
fully initialized, and therefore in the general case not "ready for
action".
It's better to call "-showWindow:" on the window controller after it's
been initialized.
j o a r
_______________________________________________
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