嗨,我有函數將數字轉換爲本地化的價格格式。 但是,當我送2000我會得到李明博2.000,00 EUR格式貨幣
ID想獲得2.000歐元(不美分)
和格式化2 000, -
-(NSString *) formatPrice:(NSString *)myPrice
{
NSNumber *price = [NSNumber numberWithInt:[myPrice intValue]];
NSLocale *priceLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@"de_DE"] autorelease]; // get the locale from your SKProduct
NSNumberFormatter *currencyFormatter = [[[NSNumberFormatter alloc] init] autorelease];
[currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[currencyFormatter setLocale:priceLocale];
NSString *currencyString = [currencyFormatter internationalCurrencySymbol]; // EUR, GBP, USD...
NSString *format = [currencyFormatter positiveFormat];
format = [format stringByReplacingOccurrencesOfString:@"¤" withString:currencyString];
// ¤ is a placeholder for the currency symbol
[currencyFormatter setPositiveFormat:format];
NSString *myPriceTitle = [currencyFormatter stringFromNumber:price];
return myPriceTitle;
}
THX
OOOOO謝謝你古茹:) – vosy
不客氣vosy :)如果你能標記爲答案,將不勝感激。乾杯! – Madhu