• 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
Subtle differences in the implementation of the Foundation framework on iPhone and OSX
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Subtle differences in the implementation of the Foundation framework on iPhone and OSX


  • Subject: Subtle differences in the implementation of the Foundation framework on iPhone and OSX
  • From: Karolis Ramanauskas <email@hidden>
  • Date: Fri, 6 Nov 2009 02:28:19 -0600

Hello there,

Thought I'll share a little observation I just made, and that cost me about
an hour to debug. This is in hope that, using my experience, you may check
for similar bugs.

Look at this piece of code:

///

 NSNumberFormatter * nf = [[[NSNumberFormatter alloc] init] autorelease];

 [nf setNumberStyle:NSNumberFormatterSpellOutStyle];

 NSNumber * result = [nf numberFromString:@" five"];

 NSLog(@"result: %@", result);

 ///

If you were to run it in 10.6, no problem, it will return 5. However on the
iPhone (or, at least, on the simulator) you'll get a beautiful (null). The
problem seems to be the space in the string in front of 'five'. Apparently
OSX implementation of NSNumberFormatter trims the string while iPhone
implementation doesn't. I noticed this because I have a project with two
targets, one for iPhone and one for OSX. My application kept returning
different results while using the same source until I found this tidbit. So
I trimmed whitespace and it's all great.

Also, are there other similar inconsistencies I should be aware of that any
of you know of?

Peace,
Thanks
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: IBOutlet getting messed up in the runtime
  • Next by Date: Re: [Moderator] Re: Apple Remote Control Wrapper sends same button ID for all buttons.
  • Previous by thread: filtered NSCollectionView
  • Next by thread: Very, Very Simple iPhone SDK Question
  • Index(es):
    • Date
    • Thread