最佳答案
我正在创建一个预算应用程序,允许用户输入他们的预算以及交易。我需要允许用户从不同的文本字段输入便士和英镑,它们需要与货币符号一起格式化。我有这个工作良好的时刻,但希望使其本地化,因为目前它只与 GBP 的工作。我一直在努力将 NSNumberFormatter 示例从 Objective-C 转换为 Swift。
My first issue is the fact that I need to set the placeholders for the input fields to be specific to the users location. Eg. Pounds and Pence, Dollars and Cents etc...
The second issue is that the values inputted in each of the text fields such as 10216 and 32 need to be formatted and the currency symbol specific to the users location needs to be added. So it would become £10,216.32 or $10,216.32 etc...
另外,我需要在计算中使用格式化数字的结果。那么,我怎样才能做到这一点,而不会遇到问题,而不会遇到问题的货币符号?