1

我的应用程序使用此行正确显示用户货币符号:

 NSString *sym = [[NSLocale currentLocale] objectForKey:NSLocaleCurrencySymbol];

当我更改设备的区域设置时,所选国家/地区的符号是正确的。

我发现货币价值似乎停留在英镑?

因此,我在 iTunes Connect 中将价格设置为 1.49 英镑,但是当我更改为显示德国 1.49 欧元而不是 1.70 欧元时?

我的印象是设备从 iTunes Connect 获得的价格是以用户货币为单位的,不是这样吗?

不用说我处于恐慌模式....有什么建议吗?

4

3 回答 3

2

除非您计划在每次显示金额时都调用货币汇率 Web 服务,否则您希望将货币符号保留在原始语言环境 (£) 中。原因是汇率波动,这在 API 中没有编程,因此价格不会在您的代码中自动更新。

当用户直接连接到 iTunes 时,他们会看到正确的价格,因为 Apple 已经在他们这边进行了货币转换。您的代码将需要进行自己的转换。

于 2011-07-14T19:35:57.640 回答
0

我得到这样的价格:

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse: (SKProductsResponse *)response {

NSArray *a = [NSArray arrayWithArray:response.products];

SKProduct *p = [a count] == 1 ? [a objectAtIndex:0] : nil;


// if we have a product store the price, otherwise 

if (p) {

    NSString *sym = [[NSLocale currentLocale] objectForKey:NSLocaleCurrencySymbol];

    [self setPriceText:[NSString stringWithFormat:@"%@%@",sym, p.price]];

    [self setProductFound:YES];
}
else {

    [self setPriceText:@"Upgrade product not found"];

    [self setProductFound:NO];        
}

[request release];

}

于 2011-07-14T20:15:19.710 回答
0

我现在发现这是显示本地化价格的正确方法:

    NSArray *a = [NSArray arrayWithArray:response.products];

SKProduct *p = [a count] == 1 ? [a objectAtIndex:0] : nil;

NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];

[numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];

[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];

[numberFormatter setLocale:p.priceLocale];

NSString *formattedString = [numberFormatter stringFromNumber:p.price];

但是,无论我在设备上设置什么语言环境,我仍然获得相同的货币价值,从我在这里的其他帖子和 Apple 文档中阅读的内容来看,我应该看到语言环境的货币价值???

于 2011-07-15T07:22:49.603 回答