• 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: runModalForWindow, best solution to modal session
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: runModalForWindow, best solution to modal session


  • Subject: Re: runModalForWindow, best solution to modal session
  • From: Alexander Reichstadt <email@hidden>
  • Date: Wed, 21 Jan 2009 20:05:42 +0100

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 (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: 
 >runModalForWindow, best solution to modal session (From: Alexander Reichstadt <email@hidden>)
 >Re: runModalForWindow, best solution to modal session (From: Keary Suska <email@hidden>)
 >Re: runModalForWindow, best solution to modal session (From: Alexander Reichstadt <email@hidden>)
 >Re: runModalForWindow, best solution to modal session (From: Ken Thomases <email@hidden>)
 >Re: runModalForWindow, best solution to modal session (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: Cursor updates - bug or programmer ignorance?
  • Next by Date: Re: Cocoa-dev Digest, Vol 6, Issue 124
  • Previous by thread: Re: runModalForWindow, best solution to modal session
  • Next by thread: Re: runModalForWindow, best solution to modal session
  • Index(es):
    • Date
    • Thread