• 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: [ot/newbie] Changing init code of widgets in Interface Builder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ot/newbie] Changing init code of widgets in Interface Builder


  • Subject: Re: [ot/newbie] Changing init code of widgets in Interface Builder
  • From: jerome LAURENS <email@hidden>
  • Date: Thu, 6 Jun 2002 10:26:59 +0200

Le jeudi 6 juin 2002, ` 09:32 AM, Carl Gherardi a icrit :

Hi,

I've got a series of drop down menus in my main application window that i'd
like to "fill" with menus from a preference file during startup.

Do I need to subclass NSPopUpButton and add it to the interface or can I
edit something else to add initialization code?

You can

- subclass NSPopUpButton and make the inialization either in the awakeFromNib or the initWithFrame
This is what you should do if the pop up is really independant from the rest of your code, Cool if you want to use your button in an NSToolbar

- connect in IB the popup to the window owner and make initializations in the "windowControllerDidLoadNib" for a NSDocument owner "windowDidLoad" for a NSWindowController owner

- create a standalone controller connected to the popup and initialize in the awakeFromNib.

- create a fake outlet as connection: just declare in interface builder the "myPopup" in the outlet part of the nib file owner class and implement a setter with no related instance variable (the same way NSDocument has a "window" outlet in interface builder but no corresponding private variable)

-(void) setMyPopup: (id) argument;
{
// do everything you wan with argument
// but do not store it (nor retain of course)
}


On the same note, I've subclassed NSView and I want to set up some default
values for variables fo the class.

I (think I) have correctly attempted to override init, but even:

- (void)/(id)init
{
NSLog(@"NSView subclass instantiating");
}

doens't print a thing.


designated initializer for NSViews is initWithFrame:

Always return the inited object from the init... method

- (id) initWithFrame: (NSRect) aFrame;
{
if(self = [super initWithFrame: aFrame])
{
// do your own initialization here
}
return self;
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Killing child tasks
  • Next by Date: Unable to Save a document
  • Previous by thread: Re: [ot/newbie] Changing init code of widgets in Interface Builder
  • Next by thread: Unable to Save a document
  • Index(es):
    • Date
    • Thread