Re: creating custom views in IB
Re: creating custom views in IB
- Subject: Re: creating custom views in IB
- From: Henri Lamiraux <email@hidden>
- Date: Fri, 3 Aug 2001 10:09:22 -0700
Do not rely on -initWithFrame: being called when unarchiving objects
from a nib. The right way to do any post nib loading initialization is
to implemement -awakeFromNib.
If you subclass an object in IB the -initWithCoder: method will be
called not the -initWithFrame;
If you use a Custom View, then yes your -initWithFrame: will be called
(because in fact the -initWithCoder: method of NSCustonView is called
and then your custom view is allocated using [[<yourClass> alloc]
initWithFrame:theFrame].
BUT at initWithXXXX time non of the outlets and actions have been set
up yet so if you override -initWithCoder: (or -initWithFrame: for custom
views) and your init routine expects outlets to be set they wont. When
-awakeFromNib is called you are sure that your object has been fully
unarchived.
On Friday, August 3, 2001, at 09:39 AM, Alex Golovinsky wrote:
I override the initWithFrame method to change some of my class
variables.
Henri Lamiraux
Engineering Manager
User Interface Tools Group
Apple