This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
window = UIWindow(frame: UIScreen.main.bounds) | |
let aVC = AViewController() | |
let nav = UINavigationController(rootViewController: aVC) | |
window!.rootViewController = nav | |
window!.makeKeyAndVisible() | |
return true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assuming .xib name is the same as class name | |
extension UIView { | |
func nibView<T>(for: T.Type) -> UIView? { | |
let nib = UINib(nibName: String(describing: T.self), bundle: nil) | |
let view = nib.instantiate(withOwner: self, options: nil).first as? UIView | |
return view | |
} | |
func addNibView<T>(from: T.Type) -> UIView? { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UITableView { | |
func registerNib<T>(from: T.Type) { | |
register(UINib(nibName: String(describing: T.self), bundle: nil), forCellReuseIdentifier: String(describing: T.self)) | |
} | |
func dequeReusableCell<T>() -> T? { | |
return dequeueReusableCell(withIdentifier: String(describing: T.self)) as? T | |
} | |
} | |
// To Use: |