Re: Universal Binaries and messages to nil
Re: Universal Binaries and messages to nil
- Subject: Re: Universal Binaries and messages to nil
- From: Keith Blount <email@hidden>
- Date: Mon, 6 Feb 2006 01:32:32 -0800 (PST)
"Note: With the release of Xcode 2.2, Objective-C
messages sent to a nil object behave the same on both
PowerPC and Intel-based Macintosh computers... On
Intel-based Macintosh computers, messages to a nil
object always return 0.0 for methods whose return type
is float, double, long double, or long long."
Thanks - I hadn't seen that, as I have yet to update
to 2.2 owing to lack of disk space.
In fact, according to the updated docs, sending
messages to nil is now safer on an Intel machine than
it is on PowerPC, so it looks like I have to change my
code anyway just to be safe on PPC:
"On PowerPC Macintosh computers, all of the same
conditions apply except that these messages
***usually*** return nil rather than always return
nil."
So although I can rely on getting 0.0 when sending
-floatValue to nil on Intel, I can't on PPC (which is
what I've been doing).
(In fact, going through my code to fix this, it seems
that I've only lapsed into the bad habit of relying on
this behaviour recently - all my older code has
checks...)
Thanks again,
Keith
--- Conor Dearden wrote:
>
>Note: With the release of Xcode 2.2, Objective-C
messages sent to a nil object
behave the same on both PowerPC and Intel-based
Macintosh computers.
You no longer have to worry about it.
>On Intel-based Macintosh computers, messages to a nil
object always return 0.0
for methods whose return type is float, double, long
double, or long long.
So your code:
NSNumber *marginWidthNumber = [[NSUserDefaults
standardUserDefaults] objectForKey:@"SCRMarginWidth"];
float marginWidth = (marginWidthNumber != nil) ?
[marginWidthNumber floatValue] : 0.0;
Is the same as:
float marginWidth = [[[NSUserDefaults
standardUserDefaults] objectForKey:@"SCRMarginWidth"]
floatValue];
You are still going to get 0.0.
Regards,
Conor
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
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