Skip to content

Instantly share code, notes, and snippets.

View SamuelFolledo's full-sized avatar
🎯
Focusing

Samuel P. Folledo SamuelFolledo

🎯
Focusing
View GitHub Profile

[TOC]

Countries Controller for any Phone TextFields

Lightweight solution on getting all the countries and its phone extension code with their names and emoji flags

Demo

Code

Country.swift

import UIKit
extension UIViewController {
/// method that instantiate a xib file given a string name using Generic
static func loadFromNib() -> Self {
func instantiateFromNib<T: UIViewController>() -> T {
return T.init(nibName: String(describing: T.self), bundle: nil)
}
return instantiateFromNib()
}