I want to find out the currency locale on user\'s iphone programmatically. That means, if user is in US Store, the currency locale should be USD, for Australia, it should be
thanks for your answer. I finally figured out that I can retrieve the price and the currency code directly from Apple:
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
NSArray *products = response.products;
if (products && products.count != 0) {
product = [products objectAtIndex:0];
[[NSNotificationCenter defaultCenter] postNotificationName:PRICE_UPDATED object:product.LocalizedPrice];
}
// finally release the reqest we alloc/init’ed in requestProUpgradeProductData
[productsRequest release];
}
@implementation SKProduct (LocalizedPrice)
- (NSString *)LocalizedPrice
{
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[numberFormatter setLocale:self.priceLocale];
NSString *formattedString = [numberFormatter stringFromNumber:self.price];
[numberFormatter release];
return formattedString;
}
@end