Re: Newbie-Initialization Question
Re: Newbie-Initialization Question
- Subject: Re: Newbie-Initialization Question
- From: Jeff LaMarche <email@hidden>
- Date: Sat, 15 Jun 2002 21:31:18 -0700
On Saturday, June 15, 2002, at 03:43 PM, Michael Hanna wrote:
>
Hi I just joined this list..
>
>
I made a very simple Cocoa/IB program that takes a number in a text field
>
and adds it to another number.
>
>
in Controller.h I initialized:
[snip]
>
the only place the compiler would let me initialize the ints was awakeFromNib:
[snip]
>
Is there a different, more elegant place to initialize?
Well, awakeFromNIB is the right place to do setting when it's necessary since
serialized objects like NIBs are already initialized by the time you load
them. I think you may find in your situation that might want to just set the
value to 0 in Interface Builder which will serialize the object initialized
to zero so your code will not be necessary. You might also, since you're dealing
with number entry, drop a number formatter on the fields.
awakeFromNIB would be the best place for this type of "initialization" (confusing
to call it that since you're not setting an initial value, you're overriding
the serialized value, so it's not really initialization), however, if you
did have conditional setting of values that you needed to do, say for example
if you needed to set them based on user preferences or other value not known
until runtime, so you're on the right track.
- Jeff
_______________________________________________
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.