• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Universal Binaries and messages to nil
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Universal Binaries and messages to nil


  • Subject: Universal Binaries and messages to nil
  • From: Keith Blount <email@hidden>
  • Date: Sun, 5 Feb 2006 14:04:58 -0800 (PST)

Hi,

Although it will be a little while before I have
access to an Intel machine, and therefore even longer
before I am able to test and release a Universal
Binary of my app, I would like to get into certain
good habits now that will ensure I have less to fix
later. With regard to this, I have a question about
universal binaries and messages to nil, which, looking
through the differences between Intel and PPC, seems
to be the difference most likely to affect my program.

As I understand it from a thread earlier this week on
Univeral Binaries, and from the documentation here:

file:///Developer/ADC Reference Library/documentation/MacOSX/Conceptual/universal_binary/index.html?file:///Developer/ADC Reference Library/documentation/MacOSX/Conceptual/universal_binary/universal_binary_tips/chapter_5_section_22.html

...I have to be more careful with messages to nil. I
would just like to clarify this, though hopefully I am
on the right track and answering my own question here.
:)

Currently, I often lazily rely on a message to (what
should be) an NSNumber returning zero if the NSNumber
is actually nil, especially when dealing with user
defaults, as in the following example:

float marginWidth = [[[NSUserDefaults
standardUserDefaults] objectForKey:@"SCRMarginWidth"]
floatValue];

I believe that on Intel, this could cause problems if
no value existed for "SCRMarginWidth", and I were
therefore calling -floatValue on nil. (Though this
wouldn't be a problem if I were calling -boolValue or
-intValue, correct?)

So, as I understand it, I would have to modify this
code as follows to be safe on Intel:

NSNumber *marginWidthNumber = [[NSUserDefaults
standardUserDefaults] objectForKey:@"SCRMarginWidth"];
float marginWidth = (marginWidthNumber != nil) ?
[marginWidthNumber floatValue] : 0.0;

Is my understanding correct? Sorry if this seems a
rather obvious question, but I want to get things
right now to try to save myself extra debugging when I
eventually do get around to converting for an Intel
machine.

Thanks in advance for any help.
All the best,
Keith

__________________________________________________
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

  • Follow-Ups:
    • Re: Universal Binaries and messages to nil
      • From: glenn andreas <email@hidden>
    • Re: Universal Binaries and messages to nil
      • From: Jim Correia <email@hidden>
  • Prev by Date: NSArrayController Difficulties
  • Next by Date: Re: Universal Binaries and messages to nil
  • Previous by thread: Re: NSArrayController Difficulties
  • Next by thread: Re: Universal Binaries and messages to nil
  • Index(es):
    • Date
    • Thread