我有一个标签,我们称之为currencyFormattedLabel,它的价值是在另一种方法中作为货币格式化(使用currencyFormatter)。如何获取货币格式标签的floatValue金额?
现在,我想使用该标签中的等效数字。但是,当我去获取数字时,我只能得到0.00的值。
也许这将有助于解释:
float x = [currencyFormattedLabel.text floatValue];
NSLog(@"x = %.2f", x);
所以,如果currencyFormattedLabel为$ 2.00,此方法始终结束返回:X = 0.00 我要的是它返回X = 2.00。
有没有办法让我currencyFormattedLabel并获得它的数字值?
感谢您的帮助!
currencyFormattedLabel.text返回什么值?这是你期望的吗? – bneely 2012-02-10 19:05:54
提示:NSLog(@“text =%@”,currencyFormattedLabel.text); – bneely 2012-02-10 19:06:20
另外,[不要使用浮动金钱](http://stackoverflow.com/questions/6333711/objective-c-issue-with-rounding-float/6334471#6334471)。你真的应该得到一个代表美分的整数值。 – 2012-02-10 19:29:29