JayVDiyk
JayVDiyk

Reputation: 4487

Listing All Countries With Codes and Calling Codes using libPhoneNumber on iOS

I came across this Stackoverflow Thread about listing countries and it's calling codes using libPhoneNumber library

The solution is this

Use the getSupportedRegions() method, then iterate these regions calling getCountryCodeForRegion().

However, the accepted solution does not apply on the iOS version of libPhoneNumber. getSupportedRegions() is not available on the iOS version

Any idea to do this in iOS using libPhoneNumber?

Upvotes: 1

Views: 982

Answers (2)

Mahgolsadat Fathi
Mahgolsadat Fathi

Reputation: 3325

solution is :

import libPhoneNumber_iOS


override func viewDidLoad() {
    super.viewDidLoad()

    let phoneUtil = NBPhoneNumberUtil()
    let regions = phoneUtil.getSupportedRegions()
}

Upvotes: 1

E. Bogren
E. Bogren

Reputation: 118

You can create your own class with a method which returns a NSSet or NSDictionary of Country Code and Country String.

Country codes can be found on wikipedia.

Upvotes: 0

Related Questions