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

Q: Designated initializers: what are they?


  • Subject: Q: Designated initializers: what are they?
  • From: email@hidden
  • Date: Sat, 12 May 2001 00:45:00 -0700

I've just spent way too much trying to debug a problem which is probably due to my lack of fundamental understanding of Cocoa, so I'm seeking enlightenment.

I wrote a custom NSView for which I wanted to implement drag and drop. It failed to receive drops because it turned out that the object never received the registerForDraggedTypes: message I was sending it from my initWithFrame: method, because this method was never called. Instead initWithCoder: was called, which I did not think to implement.

Now, the reason for my confusion is that initWithFrame: is supposed to be the "designated initializer" for the NSView class. Doesn't that mean that that's the one method that's always going to be called eventually, no matter what other initializers get called? Since that's (apparently) not the case, what does it mean to be a "designated initializer"? And am I supposed to duplicate my initialization code in every possible initializer, i.e. initWithFrame: and initWithCode:, or is there a more elegant solution?

Arno.

PS: anybody at Apple had a look at the problems with NSTextView I posted about earlier this week. Ali? Chuck? Andrew? Anyone?


  • Follow-Ups:
    • Re: Q: Designated initializers: what are they?
      • From: Ali Ozer <email@hidden>
    • Re: Q: Designated initializers: what are they?
      • From: Henri Lamiraux <email@hidden>
    • Re: Q: Designated initializers: what are they?
      • From: Izidor Jerebic <email@hidden>
  • Prev by Date: Re: NSBezierPath, illustration, 3D bezier shapes
  • Next by Date: Re: Q: Designated initializers: what are they?
  • Previous by thread: Re: NSBezierPath, illustration, 3D bezier shapes
  • Next by thread: Re: Q: Designated initializers: what are they?
  • Index(es):
    • Date
    • Thread