• 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: Q: Designated initializers: what are they?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Q: Designated initializers: what are they?


  • Subject: Re: Q: Designated initializers: what are they?
  • From: Ali Ozer <email@hidden>
  • Date: Sat, 12 May 2001 11:00:14 -0700

On Saturday, May 12, 2001, at 10:14 AM, Ali Ozer wrote:

There can be multiple designated initializers. It turns out that initWithCoder: is also an (implicit?) designated initializer for classes which archive. Thus, classes which override the DI init... methods would need to override initWithCoder: as well if they want to unarchive themselves.

So one solution is to call your common initialization from both initWithCoder: and initWithFrame:. If you're concerned about initWithCoder: just because of IB unarchiving (which is almost always the case for custom views; you normally do not archive them otherwise), then as Henri says you can use awakeFromNib instead of overriding initWithCoder:.

Of course right after posting this I remembered that initWithFrame: should still be called for custom subclasses of NSView in IB which are instantiated as views in IB; initWithCoder: is called in some less common cases. Sounds to me like your case is the common case, which should have been going through initWithFrame:. But you said initWithFrame: wasn't called at all?

Ali


  • Follow-Ups:
    • Re: Q: Designated initializers: what are they?
      • From: g <email@hidden>
References: 
 >Re: Q: Designated initializers: what are they? (From: Ali Ozer <email@hidden>)

  • Prev by Date: Re: Q: Designated initializers: what are they?
  • Next by Date: NSSound
  • Previous by thread: Re: Q: Designated initializers: what are they?
  • Next by thread: Re: Q: Designated initializers: what are they?
  • Index(es):
    • Date
    • Thread