Search code examples
iphoneobjective-clocalizationlocale

Convert NSString with a number to appropriate phone number localization format


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


Solution

  • 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.