Skip to content

Instantly share code, notes, and snippets.

@mergesort
mergesort / UIViewController+ChildViewController.swift
Created October 22, 2017 15:56
Making ChildViewControllers easier to deal with
import UIKit
extension UIViewController {
/// This function adds a `UIViewController` as a childViewController,
/// and calls the appropriate lifecycle methods.
///
/// - Parameter childViewController: The childViewController to add to the view.
func add(childViewController: UIViewController) {
self.addChildViewController(childViewController)