On Apr 15, 2010, at 1:38 PM, Chris Kane wrote:

> I think people are confusing two issues, one being the abstract "phone 
> numbers aren't numbers and NSNumberFormatter is only for quantities", and the 
> other is the reason you don't get what you want out of NSNumberFormatter, in 
> trying to explain.  Let me try to explain the latter as directly as possible.
> 
> In this kind of example of the result you want:
> 
>> format = @"(###) ###-####"
>> result = @"(123) 456-7890"
> 
> You're trying to format a number object with NSNumberFormatter and get the 
> formatter to put junk in the middle of the number [digit sequence].  
> NSNumberFormatter does not support formats putting junk in the middle of the 
> number, except for a limited set involving the thousands separator and the 
> decimal point.
> 
> 
> You're already doing the right thing for what you want to do by writing your 
> own algorithm.  You could mold that into the form of an NSFormatter subclass 
> then, if that is useful to you, or just keep it off to the side as a helper 
> function/method.
> 
> Chris Kane
> Cocoa Frameworks, Apple

Chris,

Thanks for stepping in...

I had thought about some of this every time I woke up during the night, and 
began composing a message this morning that I just posted, in reference to my 
findings.

I posted the message, checked the emails, and found your response, which agreed 
with my observations.

In the end the string2num formatter NSNumberFormatter is more of a subset of a 
true number formatter, it really should be called a currency formatter, perhaps 
NSCurrencyFormatter, or NSCurrencyDisplayFormatter. Not that I care, now that I 
understand what its target audience, and its functional scope is.

I was trying to use it within a broader scope than what it was designed for, 
and that is OK, I can certainly do workarounds. I just wanted to understand and 
use what was available instead of reinventing whatever...

It took me a while to figure this out, because I am used to number2string 
formatters that handle currency, as well as custom formats of all types.

Since I am learning the Cocoa Framework,  I prefer to use what is available, 
but I also love and thrive on work-arounds...

Thanks for clarifying and confirming my understanding...

Bill Hernandez
Plano, Texas




_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to