https://github.com/graycampbell/gccountrypicker
A localized, searchable country picker view controller with optional calling codes for iOS 9+ written in Swift.
https://github.com/graycampbell/gccountrypicker
calling-codes cocoapods country-codes country-picker international-phone-codes ios phone-number-picker picker-component swift
Last synced: 2 months ago
JSON representation
A localized, searchable country picker view controller with optional calling codes for iOS 9+ written in Swift.
- Host: GitHub
- URL: https://github.com/graycampbell/gccountrypicker
- Owner: graycampbell
- License: mit
- Created: 2017-09-28T20:18:56.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-05-04T22:39:05.000Z (almost 7 years ago)
- Last Synced: 2026-01-31T21:41:40.362Z (3 months ago)
- Topics: calling-codes, cocoapods, country-codes, country-picker, international-phone-codes, ios, phone-number-picker, picker-component, swift
- Language: Swift
- Homepage: https://graycampbell.github.io/GCCountryPicker
- Size: 39.9 MB
- Stars: 10
- Watchers: 5
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README

[](https://github.com/graycampbell/GCCountryPicker/releases/latest)
[](https://cocoapods.org/pods/GCCountryPicker)
[](https://graycampbell.github.io/GCCountryPicker)
[](https://www.codacy.com/app/graycampbell/GCCountryPicker?utm_source=github.com&utm_medium=referral&utm_content=graycampbell/GCCountryPicker&utm_campaign=Badge_Grade)
[](https://developer.apple.com/swift)

[](https://github.com/graycampbell/GCCountryPicker/blob/master/LICENSE)
### CocoaPods
```
pod 'GCCountryPicker'
```
### Implementation
1. Add GCCountryPicker to your file's import statements.
```
import GCCountryPicker
```
2. Create an instance of GCCountryPickerViewController.
```
let countryPickerViewController = GCCountryPickerViewController(displayMode: .withoutCallingCodes)
```
3. Set the delegate, data source (optional), and navigation title.
```
countryPickerViewController.delegate = self
countryPickerViewController.dataSource = self
countryPickerViewController.navigationItem.title = "Countries"
```
4. Embed the country picker view controller in a navigation controller.
```
let navigationController = UINavigationController(rootViewController: countryPickerViewController)
```
5. Present the navigation controller.
```
self.present(navigationController, animated: true, completion: nil)
```
6. Implement GCCountryPickerDelegate.
```
func countryPickerDidCancel(_ countryPicker: GCCountryPickerViewController)
func countryPicker(_ countryPicker: GCCountryPickerViewController, didSelectCountry country: GCCountry)
```
7. Implement GCCountryPickerDataSource if necessary.
```
func countryCodes(for countryPicker: GCCountryPickerViewController) -> [String]
```
### Documentation
- [Classes](https://graycampbell.github.io/GCCountryPicker/Classes.html)
- [GCCountry](https://graycampbell.github.io/GCCountryPicker/Classes/GCCountry.html)
- [GCCountryPickerViewController](https://graycampbell.github.io/GCCountryPicker/Classes/GCCountryPickerViewController.html)
- [Enumerations](https://graycampbell.github.io/GCCountryPicker/Enums.html)
- [GCCountryPickerDisplayMode](https://graycampbell.github.io/GCCountryPicker/Enums/GCCountryPickerDisplayMode.html)
- [Protocols](https://graycampbell.github.io/GCCountryPicker/Protocols.html)
- [GCCountryPickerDelegate](https://graycampbell.github.io/GCCountryPicker/Protocols/GCCountryPickerDelegate.html)
- [GCCountryPickerDataSource](https://graycampbell.github.io/GCCountryPicker/Protocols/GCCountryPickerDataSource.html)
### License
GCCountryPicker is available under the MIT license. See the [LICENSE](https://github.com/graycampbell/GCCountryPicker/blob/master/LICENSE) file for more info.