Re: NSNumberFormatter not working for me ?
Re: NSNumberFormatter not working for me ?
- Subject: Re: NSNumberFormatter not working for me ?
- From: Murat Konar <email@hidden>
- Date: Wed, 14 Apr 2010 18:54:48 -0700
I think Greg's point is that NSNumberFormatter is designed to format
numbers which represent quantities. A phone number not a quantity,
it's just a string of characters which happen to be digits.
_murat
On Apr 14, 2010, at 6:38 PM, Bill Hernandez wrote:
On Apr 14, 2010, at 5:25 PM, Greg Guerin wrote:
Your code formats strings (more specifically, characters in
strings). It does not format numbers, as such.
This is the work-around that I did because I could not make do with
NSNumberFormatter.
By "number" I mean a binary numeric value (floating-point or
integer), or possibly NSNumber or NSDecimalNumber.
I've been programming the mac since 1987 pretty much full-time. so I
promise you, I am not confused at all about what a number is, and
isn't...
All your "number" parameters are actually of the NSString* type,
not of a numeric type. The fact that the string contains digits is
incidental. In a sense, converting a numeric value to NSString* is
already a "formatting" operation, or at least a conversion operation.
I think you missed the earlier messages. You are probably looking at
the converter that I wrote as a work-around, which is basically a
numeric string formatter.
Your code would work just as well if you passed it an alphabetic
string, or one containing punctuation marks.
strippedNumber = @"SueMeTomorrow"
format = @"Social Security : ###-##-###"
result = @"Social Security : Sue-Me-Tom"
I'm not saying the digit-string isn't relevant to what you're
doing, only that what you seem to think of as a number is, in fact,
a string that happens to contain a series of digit characters. I
think that was a point an earlier reply was trying to make:
NSNumberFormatter is for numeric values (NSNumber, in particular),
not string values that happen to contain digits.
I think you missed the previous message, where someone else made
your same incorrect assumption, only to have that cleared up by Jens
Alfke. Jens picked up that I was actually using an NSNumber with the
NSNumberFormatter. Please look at the comment from Jens Alfke , and
the three lines of code below, they should clear that up for you.
only that what you seem to think of as a number is
I promise you I know what a number is...
_______________________________________________
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