https://github.com/ar4n3/countrycallingcodes
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.
https://github.com/ar4n3/countrycallingcodes
framework objective-c swift3
Last synced: about 2 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/ar4n3/countrycallingcodes
- Owner: Ar4n3
- License: mit
- Created: 2017-08-29T22:20:19.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-05-04T15:00:05.000Z (almost 6 years ago)
- Last Synced: 2025-03-13T15:16:40.234Z (about 1 year ago)
- Topics: framework, objective-c, swift3
- Language: Objective-C
- Homepage:
- Size: 142 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CountryCallingCodes
[](https://www.bitrise.io/app/fe0994beb7f761fb) [](https://codecov.io/gh/Ar4n3/CountryCallingCodes) [](https://cocoapods.org/pods/CountryCallingCodes) [](https://cocoapods.org/pods/CountryCallingCodes)
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:
```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 => :es:, code => "+34")
```objective-c
[[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:
```objective-c
#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 => :es:, code => "+34")
```swift
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:
```swift
//MARK: Delegate methods
func updateCountryData() {
let buttonString = String.init(format: "%@\t%@", CountryCallingCode.sharedInstance().flag, CountryCallingCode.sharedInstance().code)
countryButton.setTitle(buttonString, for: .normal)
}
```