3

NSString *phoneNumber = @"2310234432"; I would like to create a new string out of the above but format the phone number according to the current localization. Is there a "native" way I can do this or do I have to write my own methods to return it for every locale ?

Thanx

2 Answers2

7

Apple has not provided a public API for displaying localised phone numbers, so this is a non-trivial task. Back in iPhone OS 2.x, Apple packaged a filed within the SDK called UIPhoneFormats.plist which provided a list of all the phone localisation formats, but they've since removed it from recent OSes and SDKs.

Please make sure you file a radar:// bug for this, because it's a common request.

Nathan de Vries
  • 15,481
  • 4
  • 49
  • 55
0

There is nothing that can do this.

And in fact is it probably not a good idea to store phone numbers in NStrings Think about 1-800-COLLECT. Convert that to numbers, and the friendly phone number is gone.

Mihai Nita
  • 5,547
  • 27
  • 27
  • 1
    Who talks about converting? You could leave that phone number as is if it contains some letters, but if consists of numbers, why not to format it according to user's preferences? – Stas Sep 11 '12 at 10:09