Hi Ken,

On 17.01.2009, at 17:51, Ken Thomases wrote:

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.
That's the problem, see beginning of this thread. The initial problem was that regardless of what initializer I used, none would give me a window. I thought that if in the end all initializers of NSWindowController do call initWithWindow I try that. Someone else off- list was certain that init would only give me an object and not take care of all else that should be taken care of when initializing a window controller.

        [...]
}

- (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

I think I go with the second option.

Thanks
Alex

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to