Re: Need help to make this method prettier
Re: Need help to make this method prettier
- Subject: Re: Need help to make this method prettier
- From: Andre Masse <email@hidden>
- Date: Sun, 02 Nov 2008 08:54:03 -0500
I tried at first to use the standard NSNumberFormatter in IB but
couldn't find the right pattern.
Your solution works great and don't require subclassing so thanks a lot.
Andre Masse
On Nov 1, 2008, at 16:09, Bill Bumgarner wrote:
Use the APIs whenever possible.
int main (int argc, const char * argv[]) {
NSArray *a = [NSArray arrayWithObjects:
[NSNumber numberWithUnsignedLongLong: 12],
[NSNumber numberWithUnsignedLongLong: 1234],
[NSNumber numberWithUnsignedLongLong: 12345678],
[NSNumber numberWithUnsignedLongLong:
123456789012345678],
nil];
NSNumberFormatter *nf = [NSNumberFormatter new];
[nf setNumberStyle: NSNumberFormatterDecimalStyle];
[nf setGroupingSeparator: @" "];
for(NSNumber *n in a)
NSLog(@"%@ => %@", n, [nf stringFromNumber:n]);
return 0;
}
Spews:
2008-11-01 13:05:46.881 format[1350:10b] 12 => 12
2008-11-01 13:05:46.882 format[1350:10b] 1234 => 1 234
2008-11-01 13:05:46.883 format[1350:10b] 12345678 => 12 345 678
2008-11-01 13:05:46.883 format[1350:10b] 123456789012345678 => 123
456 789 012 345 678
b.bum
_______________________________________________
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