Convert NSString with a number to the appropriate format for localizing a phone number

NSString * phoneNumber = @ "2310234432"; I would like to create a new line from the above, but format the phone number according to the current localization. Is there an β€œown” way that I can do this, or do I need to write my own methods to return it for each locale?

Thanx

+3
source share
2 answers

Apple has not provided a public API to display localized phone numbers, so this is not a trivial task. Back in iPhone OS 2.x, Apple packaged in an SDK called UIPhoneFormats.plist, which provided a list of all phone localization formats, but they have since removed it from the latest OS and SDKs.

Please make sure you radar://provide an error for this, because this is a general request.

+7
source

There is nothing to do this.

And actually, it's probably a good idea to store phone numbers in NStrings. Think about 1-800-COLLECT. Convert it to a number and the friendly phone number has disappeared.

0
source

Source: https://habr.com/ru/post/1716966/


All Articles