Re: Allocation during awakeFromNib
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.