NSNumberFormatter to format US Telephone Numbers

后端 未结 5 1419
执念已碎
执念已碎 2020-12-06 12:35

I\'m trying to convert a string of numbers, entered by the user, into a sexy string like Phone.app on the iPhone. Here is the code I\'m using, which doesn\'t work (no specia

5条回答
  •  自闭症患者
    2020-12-06 13:16

    One thing that is never mentioned here is that a NSNumberFormatter will always convert the value into, well, a NSNumber. If you want a more generalized NSFormatter, subclass NSFormatter and implement the methods mentioned in the Creating a Custom Formatter.

提交回复
热议问题