• 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: Allocation during awakeFromNib
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Allocation during awakeFromNib


  • Subject: Re: Allocation during awakeFromNib
  • From: Chris Hanson <email@hidden>
  • Date: Fri, 2 Jan 2004 22:18:38 -0600

On Jan 2, 2004, at 10:44 AM, Darrin Cardani wrote:
I have a subclass of NSMovieView. In the subclass I need to allocate an NSMutableArray during initialization. Normally, I'd do the allocation in one of the init methods, but it doesn't appear that any of the init methods get called. (I've overridden -initWithFrame: and -init, and neither is ever called.)

How are you instantiating your NSMovieView subclass in Interface Builder?

If you drag an NSMovieView out of the palette and into a window, and then use the Custom Class inspector to set its class, it will be initialized via -initWithCoder:. This is because nib loading is really just unarchiving.

If you drag a "Custom View" out of the palette and into a window, on the other hand, it will be initialized via -initWithFrame:.

The main reason for this is the use of the NSCoding protocol. An -initWithCoder: method is supposed to send -initWithCoder: to super, if the superclass implements NSCoding; otherwise, it's supposed to send super's designated initializer. So why isn't your -initWithFrame: being called? Because NSView isn't the topmost class in the hierarchy that implements NSCoding, NSResponder is, for whatever reason, and it's not documented as having *any* designated initializer...

-- Chris

--
Chris Hanson <email@hidden>
bDistributed.com, Inc.
Outsourcing Vendor Evaluation
Custom Mac OS X Development
Cocoa Developer Training
_______________________________________________
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: 
 >Allocation during awakeFromNib (From: Darrin Cardani <email@hidden>)

  • Prev by Date: Re: Good example code for an Inspector/Get Info window?
  • Next by Date: Re: [NSPlaceholderDictionary initWithObjects:forKeys:]
  • Previous by thread: Allocation during awakeFromNib
  • Next by thread: Re: Allocation during awakeFromNib
  • Index(es):
    • Date
    • Thread