Re: Phantom views? was RE: [Newbie] Uninitialized outlets?
Re: Phantom views? was RE: [Newbie] Uninitialized outlets?
- Subject: Re: Phantom views? was RE: [Newbie] Uninitialized outlets?
- From: "Erik M. Buck" <email@hidden>
- Date: Thu, 6 Sep 2001 12:59:54 -0500
If you have a custom view (dragged from the palette) AND you instantiated
the view subclass then you have two instances in the nib. Don't instantiate
a subclass of view using the menu item. Instances of view subclasses should
not be in the "instances" window. The "Custom View" that you drag from the
palette IS the instance of the subclass of view once you set its custom
class.
You wrote:
"
I've looked into this a bit more. Something I just discovered is that
my custom view's -initWithFrame and awakeFromNib methods are called
twice, with two different "self" values. The call stack on each method
invocation is identical though:
"
You definitely have TWO different instances. That is what self IS.
In retrospect, I can see how easy it might be to think you have to
instantiate your View subclass explicitly, but if you think about it, Views
are special. The act of dragging the view from the palette instantiates it.
When you drag a button (a subclass of view) from the palette you do not also
instantiate the button with the menu. When you drag the Custom View from
the palette, you are effectively instantiating it and telling it to replace
itself with a custom subclass of view when the nib is loaded.