Re: checking if an object's instance exists.
Re: checking if an object's instance exists.
- Subject: Re: checking if an object's instance exists.
- From: daniel <email@hidden>
- Date: Sat, 5 Feb 2005 14:12:36 -0800
I think it's a C++ habit that really belong in Objective C code. Sure,
it does no harm, but it's a waste of work and code. If clarity is all
you're after, you might as well put a comment in your init routine:
// Reminder: the following ivars, like all ivars in Objective C, are
initialized to zero automatically:
//
// ...
You might be right about nib loading being a poor analogy, but
ironically you take much "nil by default" behavior simply by using a
nib to instantiate your objects. You say you set everything in the nib
file, but you don't You instantiate objects and configure some of
their ivars. I doubt IB goes through and sets "nil" on every delegate
connection that you don't make, for instance. You're taking advantage
of a feature of the language/runtime.
To be clear, I'm just sort of enjoying this as a pedantic debate at
this point. I don't really think there's anything wrong with
redundantly setting variables to nil. Just that it's redundant, so I
won't bother with it, myself.
Daniel
On Feb 5, 2005, at 12:14 PM, Kevin Ballard wrote:
With IBOutlet, you have set everything in the nib file. With ivars, I
think it adds clarity to init them to nil or 0 or whatever in the
initializer for clarity. That way I can look at the initializer and
find what the default value is - whether it's nil/0 or whether it's
some other preset value. But I do recognize that this is simply
preference, just like whether or not you put the opening brace of a
method on the same line as the method name or on the next line.
_______________________________________________
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