iPhone NSNumberFormatter setFormat:

北城余情 提交于 2019-11-30 12:10:19

Yes, it's documented as a note in the NSNumberFormatter Class Reference (requires login). The note says:

iPhone OS Note: iPhone OS supports only the modern 10.4+ behavior. 10.0-style methods and format strings are not available on iPhone OS.

EDIT: Added more text to support follow-up questions.

You could re-write yours to something similar:

NSNumberFormatter *lengthFormatter = [[NSNumberFormatter alloc] init];
[lengthFormatter setNumberStyle:NSNumberFormatterDecimalStyle];
[lengthFormatter setPositiveSuffix:@"M"];
[lengthFormatter setNegativeSuffix:@"M"]; // assuming it can go negative

I suggest taking a look at the document that I linked above. It's specifically for the iPhone version of NSNumberFormatter, so none of the methods that will cause your application to crash are in there. It's also designed to take far more advantage of the user's localized settings than the original NSNumberFormatter did. There are groups of methods for restricting what shows up and such while still taking advantage of the user's preferences. Unfortunately, there is no longer a setFormat: method.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!