• 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: init with parameters for objects in interface builders
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: init with parameters for objects in interface builders


  • Subject: Re: init with parameters for objects in interface builders
  • From: "Clark S. Cox III" <email@hidden>
  • Date: Tue, 15 Oct 2002 14:26:45 -0400

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On Tuesday, Oct 15, 2002, at 13:06 US/Eastern, Louis Foucart wrote:

They are subclasses of NSObject. The problem is that they are created by the application when it processes the nib file. I don't have any control on the init phase of these objects.
So I have a main class (a NSView) which should initialize other objects in its initWithFrame method. The fact is that some objects (IBOutlets) are null when I want to init them.
Sample:
I have a custom NSView and a custom NSObject called controller initialized in the nib file.
The NSView interface looks like this :
IBOutlet Controller controller;

The NSView method looks like this:
- (void)initWithFrame:(NSRect)frame {
...
[controller initWithX:frame.x y:frame.y]; // I need objects specified earlier in this method, for example frame is defined in the nib file
}

But controller is null when NSView initWithFrame is called.
Where can I put my init call on controller ?
Is there something nicer than call a setup method from the controller on the view, which method will call back initWithx:y: on the controller ?

Don't rely on outlets being connected inside init... methods. The init... methods are only for initializing a single object, not dealing with the relationships between seperate objects. Initialization code that relies on IB connections should go inside -awakeFromNib, by the time awakeFromNib is called, you know that the connections have been made.

- -- http://homepage.mac.com/clarkcox3/
email@hidden
Clark S. Cox, III
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (Darwin)

iEYEARECAAYFAj2sXesACgkQd6STocYT1xUjIwCgmX8RCTtxFY9egXBZR6Zvo1wq
a+IAoIbFdakoitjHsC45cPriNhb6lP+d
=3puq
-----END PGP SIGNATURE-----
_______________________________________________
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.

References: 
 >Re: init with parameters for objects in interface builders (From: Louis Foucart <email@hidden>)

  • Prev by Date: Re: Cocoa-nuts!
  • Next by Date: Re: Keyboard shortcuts for views in toolbar items
  • Previous by thread: Re: init with parameters for objects in interface builders
  • Next by thread: Calling down the NSText gods!
  • Index(es):
    • Date
    • Thread