Developer

MAFCurrencyFormatter

MAFCurrencyFormatter formats currency values according to country ISO code. Formatted numerical values are delimited by colons or periods, depending on the ISO code, and the currency symbol (if any); or its alphabetical code is prefixed to the digits.

Before creating a formatter instance, load the currency and country metadata by calling the static method on the MAFDefaultCurrencySettings class:
[MAFDefaultCurrencySettings loadCurrencies];
Next, specify first the ISO code, then create a MAFCurrencyFormatterSettings object, and pass length settings and formatting flags to it:
NSString* isoCode = @"HUF";
int decimals = [[MAFCurrencyCatalog currencyCatalog] decimalsByISO:isoCode];
MAFCurrencyFormatterSettings* settings = [[MAFCurrencyFormatterSettings alloc] initWithLength:18 andDecimalPlaces:decimals andFlags:CURRENCY_FORMATTER_FLAG_SIGNED | CURRENCY_FORMATTER_FLAG_ALLOWS_NULL];
The length parameter defines a range, and all input values must be within that range. You can define constraints with flags, for example, whether the formatter accepts null, or signed values. After defining an ISO code string and other settings, create a currency formatter by directly calling the alloc/init methods of the MAFCurrencyFormatter:
MAFCurrencyFormatter* currencyFormatter = [[[MAFCurrencyFormatter alloc] initWithDecimalNumber:nil andSettings:settings andISOCurrencyCode:isoCode] autorelease];
[settings release]; // we do not need to hold a reference to the settings after setting it for the alloc/init
You can set any decimal number value inputs for the formatter instance, then request formatter values:
[currencyFormatter setValue:[NSDecimalNumber decimalNumberWithDecimal:[[NSNumber numberWithInt:1423196924] decimalValue]]];

NSLog(@"FORMATTED VALUE> %@", [currencyFormatter getFormattedValue]);
This code shows the formatted currency value according to the Hungarian format:

FORMATTED VALUE> HUF1,423,196,924