Re: [myWindowController window] returns null !
Re: [myWindowController window] returns null !
- Subject: Re: [myWindowController window] returns null !
- From: Kyle Sluder <email@hidden>
- Date: Wed, 23 Feb 2011 21:22:15 -0800
On Wed, Feb 23, 2011 at 8:55 PM, Louis Demers <email@hidden> wrote:
> I temporarily set the File's Owner type to a NSWindowController class and connected the window to it. Got the same null value
Rather than trash at the answer, it would be more helpful to learn the
meaning behind your actions.
If you set the File's Owner class to NSWindowController, but didn't
change the owner you passed to -initWithWindowNibName:owner:, then of
course it wouldn't work. The Class Identity of the File's Owner proxy
in the nib is strictly informative; the actual class of File's Owner
is the class of whatever you pass in as the owner.
There's very little reason to use -initWithWindowNibName:owner:. It's
much more typical to subclass NSWindowController and use
-initWithWindowNibName: instead. But if you're going to use
-initWithWindowNibName:owner:, you'll need some outlet on the owner
object to which you connect your window. Then you can do something
like this:
@interface MyFilesOwner : NSObject
@property(assign) IBOutlet NSWindow *windowOutlet; // Hooked up to window in nib
@end
// -=-=-=-
MyFilesOwner *owner = [[MyFilesOwner alloc] init];
NSWindowController *windowController = [[NSWindowController alloc]
initWithWindowNibName:@"NibFile" owner:owner];
[windowController setWindow:[owner windowOutlet]];
//END
But again, there's rarely any reason to prefer this to than merely
subclassing NSWindowController and letting it be the File's Owner,
which is the default behavior when you call -initWithWindowNibName:.
--Kyle Sluder
_______________________________________________
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