How to get the user's country calling code in iOS?

后端 未结 13 1949
终归单人心
终归单人心 2020-12-23 13:24

I am developing an iOS app in which the user enters their mobile number. How do I get their country calling code? For example, if a user is in India, then +91 s

相关标签:
13条回答
  • 2020-12-23 13:49

    with the use of NSLocale you can get the country name, code etc. Take a look at below code it will help you to do so.

    NSLocale *currentLocale = [NSLocale currentLocale];  // get the current locale.
    NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode]; // get country code, e.g. ES (Spain), FR (France), etc.
    

    for a countries dialing code you can visit this reference code.

    0 讨论(0)
提交回复
热议问题