Two odd newbie questions ;-)
Two odd newbie questions ;-)
- Subject: Two odd newbie questions ;-)
- From: Felix Schwarz <email@hidden>
- Date: Thu, 12 May 2005 20:33:18 +0200
Hi everyone,
I'm (pretty) new to Objective-C programming. One thing I keep
wondering about, is whether I can safely write e.g.
myFloat = [[valueLimits objectForKey:myKey] floatValue];
or should rather write:
if (myNsFloat = [valueLimits objectForKey:myKey])
{
myFloat = [myNsFloat floatValue];
}
The same goes with
[new retain];
[old release];
old = new;
instead of
if (new)
{
[new retain];
}
if (old)
{
[old release];
}
old = new;
Is it legal to perform methods on (or send messages to) "null" or
"nil" objects?
Is there a guaranteed result (thinking of above myFloat example -
will it be null in case the dictionary does not contain the key or
have an undefined value?)?
I ask those questions because - most of the time - I don't see *any*
error checking in place in sample code, so I wonder whether the
sample code simply is written in a bad style or it uses a "feature"
of the language or Cocoa.
Thanks in advance!
Best regards,
Felix Schwarz
_______________________________________________
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