• 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: 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


  • Follow-Ups:
    • Re: runModalForWindow, best solution to modal session
      • From: Alexander Reichstadt <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>)

  • Prev by Date: Re: Displaying multiple core data relationships in NSOutlineView
  • Next by Date: Re: modifier-flags with no key pressed and mouseDown 256, why?
  • Previous by thread: Re: runModalForWindow, best solution to modal session
  • Next by thread: Re: runModalForWindow, best solution to modal session
  • Index(es):
    • Date
    • Thread