Re: NSNumberFormatter not working for me ?
Re: NSNumberFormatter not working for me ?
- Subject: Re: NSNumberFormatter not working for me ?
- From: Bill Hernandez <email@hidden>
- Date: Tue, 13 Apr 2010 18:10:52 -0500
On Apr 13, 2010, at 5:39 PM, Keary Suska wrote:
> I think the issue remains that the format you are passing is not considered a valid format, and is getting ignored. You can confirm this by providing a valid number format for comparison. I tend to use a custom formatter for this purpose, keeping the phone number as a string. It is more robust and allows for non-U.S. number that may begin with 0.
Keary,
I can do the following :
// +---------+---------+---------+---------+---------+---------+---------+---------+
- (void)awakeFromNib
{
// I have already run a routine to strip all non digits by this time
NSString *strippedNumber = @"1234567890";
NSString *phoneNumber;
BOOL useFormatter = NO;
if(useFormatter)
{
phoneNumber = [BHUtility bhFormatNumberString:strippedNumber withFormat:@"(###) ###-####"];
}
else
{
if([strippedNumber length] == 10)
{
NSString *areacode = [strippedNumber substringWithRange:NSMakeRange(0, 3)];
NSString *exchange = [strippedNumber substringWithRange:NSMakeRange(3, 3)];
NSString *number = [strippedNumber substringWithRange:NSMakeRange(6, 4)];
phoneNumber = [NSString stringWithFormat:@"(%@) %@-%@", areacode, exchange, number];
}
else
{
phoneNumber = strippedNumber;
}
}
NSLog(@"[4626] phoneNumber = %@", phoneNumber);
}
// +---------+---------+---------+---------+---------+---------+---------+---------+
but this was part of learning another little piece of Cocoa. I started trying to learn a little Cocoa around the end of the year,I think December, and have come a long way, but every time I think I am making progress I realize it is going to take a long time...
Thanks for trying to help...
Bill Hernandez
Plano, Texas
_______________________________________________
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