Subtle differences in the implementation of the Foundation framework on iPhone and OSX
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