Re: First-Time Help Needed: Instantiating a Subclass in IB
Re: First-Time Help Needed: Instantiating a Subclass in IB
- Subject: Re: First-Time Help Needed: Instantiating a Subclass in IB
- From: John Bishop <email@hidden>
- Date: Fri, 14 Oct 2005 22:10:47 -0500
Jerry Krinock <email@hidden> said:
>My problem: At run-time, my subclass' -initWithFrame method doesn't run for
>this field. The field still acts like a plain old NSTextField.
Because at run time, the instance of your subclass isn't initialized with
initWithFrame:, it's initialized (from the nib) with initWithCoder: Check out
the <NSCoding> protocol, to which lots of NSObjects (but not NSObject) conform
- notably, in your case, an NSTextField.
If you'll implement initWithCoder: in your subclass (and I'll refrain from
asking why you'd WANT to subclass NSTextField), you can handle any special
initialization there. Don't forget to invoke [super initWithCoder:] when you
do!
Happy coding!
--
"One of the advantages bowling has over golf is that you seldom lose a bowling ball." Don Carter
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden