Localized phone number formatting

前端 未结 5 2071
时光说笑
时光说笑 2020-12-09 18:36

I\'ve looked into NSFormatter, NSNumberFormatter, and the other formatting classes, but can\'t find a build into solution. I need to format phone n

5条回答
  •  温柔的废话
    2020-12-09 19:21

    You can try this:

        let phoneNumber : CNPhoneNumber
        let digits = phoneNumber.performSelector("digits").takeRetainedValue() as! String
    

    It gives you directly the string, without formatting, with the phone number. However if the number is saved with international prefix, you will have it also in the resulted string.

提交回复
热议问题