• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Need help to make this method prettier
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Re: Need help to make this method prettier (From: Graff <email@hidden>)
 >Re: Need help to make this method prettier (From: Bill Bumgarner <email@hidden>)

  • Prev by Date: Nearly have NSPopUpButtonCell working, need help for one binding
  • Next by Date: Re: Tracking changes to NSTableView datasource
  • Previous by thread: Re: Need help to make this method prettier
  • Next by thread: Re: NSTextView actions
  • Index(es):
    • Date
    • Thread