使用 NSNumberFormatter
我有一个问题正在寻找答案。我不太了解 NSNumberFormatter。我盯着文档看了一会儿,似乎无法理解为什么我根本无法让 setMinimum (或 setMaximum)工作。
这是我正在使用的代码:
NSNumberFormatter* numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
[numberFormatter setMinimum:[NSDecimalNumber decimalNumberWithString:@"2"]];
[numberFormatter setMaximum:[NSDecimalNumber decimalNumberWithString:@"2"]];
[numberFormatter setMultiplier:[NSNumber numberWithDouble:1]];
//[numberFormatter setMaximumFractionDigits:OVER9000];
NSLog(@"%@, %@", [numberFormatter stringFromNumber:[NSNumber numberWithDouble:1.123456789]], [numberFormatter stringFromNumber:[NSNumber numberWithDouble:0.8]]);
我一直在玩类似的东西,我的计划是会发生一些事情,但它看起来确实没有发生任何事情(即在控制台中,我得到 1, 1 )...
I have a question that I am looking for the answer to. I am not really understanding NSNumberFormatter. I've stared at the documentation for a while, and can't seem to understand why I can't get setMinimum (or setMaximum) to work at all.
Here is the code I am using:
NSNumberFormatter* numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
[numberFormatter setMinimum:[NSDecimalNumber decimalNumberWithString:@"2"]];
[numberFormatter setMaximum:[NSDecimalNumber decimalNumberWithString:@"2"]];
[numberFormatter setMultiplier:[NSNumber numberWithDouble:1]];
//[numberFormatter setMaximumFractionDigits:OVER9000];
NSLog(@"%@, %@", [numberFormatter stringFromNumber:[NSNumber numberWithDouble:1.123456789]], [numberFormatter stringFromNumber:[NSNumber numberWithDouble:0.8]]);
I've been playing around with stuff like that and my plan was that something would happen, but it really doesn't look like anything is going on (i.e. in the console, I get 1, 1)...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为您实际上并没有问问题,所以这里有一个关于 NSNumberFormatter
下次提出问题,您可以获得更多帮助。
Since you didn't actually ask a question here's a link about NSNumberFormatter
Next time ask a question and you can get more help.