CountryCallingCodes 0.1.1

CountryCallingCodes 0.1.1

Maintained by Enara L.Otaegui.



  • By
  • Ar4n3

CountryCallingCodes

Build Status codecov pod license

A simple and easy way to get the international calling code and Emoji flag from a selected Country. Demos are provided in Objective-C and Swift.

Installation

You can download this project, or you can install it via Cocoapods:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'

target 'TargetName' do
pod 'CountryCallingCodes'
end

How to use

Objective-C

Get the default data for your device locale (e.g. flag => 🇪🇸, code => "+34")

[[CountryCallingCode sharedInstance] setDelegate:self];
NSString *buttonString = [NSString stringWithFormat:@"%@\t%@", [CountryCallingCode sharedInstance].flag, [CountryCallingCode sharedInstance].code];
[_countryButton setTitle:buttonString forState:UIControlStateNormal];

To select another country, make a segue to storyboard reference and on your delegate implement:

#pragma mark - Delegate Methods

- (void)updateCountryData {
    NSString *buttonString = [NSString stringWithFormat:@"%@\t%@", [CountryCallingCode sharedInstance].flag, [CountryCallingCode sharedInstance].code];
    [_countryButton setTitle:buttonString forState:UIControlStateNormal];
}

Swift

Get the default data for your device locale (e.g. flag => 🇪🇸, code => "+34")

CountryCallingCode.sharedInstance().delegate = self
let buttonString = String.init(format: "%@\t%@", CountryCallingCode.sharedInstance().flag, CountryCallingCode.sharedInstance().code)
countryButton.setTitle(buttonString, for: .normal)

To select another country, make a segue to storyboard reference and on your delegate implement:

//MARK: Delegate methods
func updateCountryData() {
   let buttonString = String.init(format: "%@\t%@", CountryCallingCode.sharedInstance().flag, CountryCallingCode.sharedInstance().code)
   countryButton.setTitle(buttonString, for: .normal)
}