Re: runModalForWindow, best solution to modal session
Re: runModalForWindow, best solution to modal session
- Subject: Re: runModalForWindow, best solution to modal session
- From: Ken Thomases <email@hidden>
- Date: Sat, 17 Jan 2009 10:51:54 -0600
On Jan 16, 2009, at 2:06 AM, Alexander Reichstadt wrote:
@implementation KSingleItemSelectorController
#pragma mark -
#pragma mark Init+Dealloc
+ (id)selectItemUsingFenstertyp:(NSString *)aFenstertyp
withComposition:(NSString *)aKomposition
{
KSingleItemSelectorController *newXelector = [[self alloc]
initWithWindow:nil];
Why are you initializing your window controller with a window, and a
nil window at that, rather than with a nib name? If you want the
window controller to load the window to be controlled from a nib, tell
it to do that directly.
[...]
}
- (id)initWithWindow:(NSWindow *)aWindow
{
if ((self = [super initWithWindow:aWindow])){
[NSBundle loadNibNamed:[self windowNibName] owner:self];
return self;
}
return nil;
}
You don't need to override the initWithWindow: method. The usual
pattern with window controller subclasses is to either: 1) don't
override any of the initializers (at least not for the purpose of nib
loading) and instead have the code with allocates and initializes the
object invoke -initWithWindowNibName:, or 2) override plain old -init
and have the subclass hard-code the name of the nib it manages when it
invokes [super initWithWindowNibName:YourNibName].
Regards,
Ken
_______________________________________________
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