App Store的本地化价格

时间:2010-03-05 13:48:51

标签: iphone objective-c cocoa-touch app-store

我将同一家公司的其他应用程序链接到iPhone应用程序中,我们希望显示这些应用程序的价格。是否有可能以某种方式获得适合用户的本地化价格字符串(金额和货币)?我想我不得不求助于屏幕抓取,但我看到人们可以从App Store获得大量信息,所以也许有一些相对简单的方法?

2 个答案:

答案 0 :(得分:6)

您可以使用iTunes Web服务API。

http://www.apple.com/itunesaffiliates/API/AffiliatesSearch2.1.pdf记录它。

您可以使用“国家/地区”查询字段来指定您希望返回结果的国家/地区。

您可以使用NSLocale

获取用户的国家/地区名称
NSLocale *locale = [NSLocale currentLocale];
NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];
NSString *countryName = [locale displayNameForKey: NSLocaleCountryCode
                         value: countryCode]];

虽然你可能需要一个查找表来格式化这个,就像iTunes商店API一样。

答案 1 :(得分:0)

如果您可以将价格提取为简单数字,NSNumberFormatter将为您提供货币本地化。

NSDecimalNumber *price = [NSDecimalNumber decimalNumberWithString:@"4.95"];

NSNumberFormatter *currencyFormatter = [[NSNumberFormatter alloc] init];
[currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];

这将从用户默认区域设置中添加货币。如果要更改区域设置,请使用:

[currencyFormatter setLocale:anyLocale];
相关问题