• 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: Overiding NSButton initWithFrame: (doesn't work)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Overiding NSButton initWithFrame: (doesn't work)


  • Subject: Re: Overiding NSButton initWithFrame: (doesn't work)
  • From: email@hidden
  • Date: Sat, 2 Feb 2002 10:58:21 -0800

Now I remember running into the same dilemma before. Its best not to
duplicate code in multiple places yet there is no single init function
which is guaranteed to be called. Some initialization needs to take
place no matter whether the instance was progromatically created or
decoded from a nib. What is the most elegant solution?

Off the top of my head its probably best to call my own universal init
routine from awakeFromNib, initWithFrame, and initWithCoder if I want to
ensure that the same block of code is always used for initialization.Yes?

If you do it from both -initWithCoder and -awakeFromNib it will be called twice, I believe. This is a perfect example of the sort of initialization that does not belong in -awakeFromNib, IMHO.
And yes, calling a shared initialization method (after calling super's init method) seems like the best way to handle this, and I've done this many times in my code.

Ben Haller
Stick Software


  • Prev by Date: Re: optimizing compilers
  • Next by Date: GCC 3.0/Darwin Wishlist
  • Previous by thread: Re: Overiding NSButton initWithFrame: (doesn't work)
  • Next by thread: Re: NSBrowser Question
  • Index(es):
    • Date
    • Thread