On Nov 1, 2008, at 1:56 PM, Andre Masse wrote:
I'm implementing a custom NSFormatter. I want a number with 9 digits displayed as "123 456 789". So before implementing the formatter I made a test project to check the conversion. The version I did get the job done but its not pretty :-) Any more good looking solutions?
Just a quick example: // get a number by any means possible unsigned int theNumber = 1123456789; // truncate numbers that are too large theNumber = theNumber % 1000000000; NSMutableString *numberString; // turn the number into a string padded with zeros to 9 places numberString = [NSMutableString stringWithFormat:@"%09d", theNumber]; // add a space character to position 6 [numberString insertString:@" " atIndex:6]; // add a space character to position 3 [numberString insertString:@" " atIndex:3]; // numberString is now formatted in the format "xxx xxx xxx" _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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]