Spell Out Number As Text

This tips shows how to output a numeric value spelled out as text. As an example, when writing a check you enter a numeric value: $99 as well as the spelled out variation of the same: ninety nine.

Let’s look at two examples:

// Number to output
NSNumber *value = [NSNumber numberWithInt:18099306];
// Create formatter
NSNumberFormatter *formatter = [[[NSNumberFormatter alloc] init] autorelease];
// Set formatter style to spell out
[formatter setNumberStyle: NSNumberFormatterSpellOutStyle];
NSLog (@"Numeric: %@\nText: %@", value, [formatter stringFromNumber:value]);

The output will look as follows:
Continue reading