Re: initWithFrame not being called on my NSImageView subclass
Re: initWithFrame not being called on my NSImageView subclass
- Subject: Re: initWithFrame not being called on my NSImageView subclass
- From: "Kyle Sluder" <email@hidden>
- Date: Thu, 21 Feb 2008 16:46:08 -0500
On Thu, Feb 21, 2008 at 2:41 PM, Ken Ferry <email@hidden> wrote:
> What's guaranteed is that all init methods on a class will funnel into
> one of the designated init methods. A subclasser should always
> override all designated initializers of the superclass (if he needs to
> do work at initialization time). Then you're guaranteed to have your
> setup performed no matter how the object is created.
What I'm saying is that I'm not sure this is guaranteed to be true for
unarchiving. Since (with rare exception) any override of a designated
initializer is supposed to call super's implementation, it would be
very easy to introduce improper behavior by calling -[NSView
initWithFrame:] at design time, archiving the object graph into the
nib, and then calling -[MyView initWithFrame:], which then invokes
-[NSView initWithFrame:], when unarchiving the view from the nib.
I think the Apple docs are pretty clear that there is no guarantee
whatsoever that any initializer will be called on your objects when
unarchiving from a nib. The nib unarchiving mechanism doesn't really
care about your setters, getters, and initializers. It restores
whatever state it knew about when it archived the object, trusting you
to implement -awakeFromNib if you need subclass-specific processing.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden