<commit_before>//
//  UIViewControllerExtensions.swift
//  VOKUtilities
//
//  Copyright © 2019 Vokal. All rights reserved.
//

import UIKit

extension UIViewController {
    /// Add a child view controller.
    ///
    /// - Parameter child: the child view controller to add.
    public func addChildVC(_ child: UIViewController) {
        child.beginAppearanceTransition(true, animated: false)
        addChild(child)
        child.view.pin(to: view)
        child.didMove(toParent: self)
        child.endAppearanceTransition()
    }
    
    /// Remove self from the parent view controller.
    public func removeFromParentVC() {
        guard parent != nil else { return }
        
        beginAppearanceTransition(false, animated: false)
        willMove(toParent: nil)
        view.removeFromSuperview()
        removeFromParent()
        endAppearanceTransition()
    }
    <commit_msg>Refactor add child view controller method<commit_after>//
//  UIViewControllerExtensions.swift
//  VOKUtilities
//
//  Copyright © 2019 Vokal. All rights reserved.
//

import UIKit

extension UIViewController {
    /// Add a child view controller.
    ///
    /// - Parameter child: the child view controller to add.
    /// - Parameter pinningView: the view to pin the child VC's view to. Default is nil which will pin to the parent
    ///   VC's main view.
    public func addChildVC(_ child: UIViewController, pinningView: UIView? = nil) {
        child.beginAppearanceTransition(true, animated: false)
        addChild(child)
        child.view.pin(to: pinningView ?? view)
        child.didMove(toParent: self)
        child.endAppearanceTransition()
    }
    
    /// Remove self from the parent view controller.
    public func removeFromParentVC() {
        guard parent != nil else { return }
        
        beginAppearanceTransition(false, animated: false)
        willMove(toParent: nil)
        view.removeFromSuperview()
        removeFromParent()
        endAppearanceTransition()
    }
    
{'fraction_non_alphanumeric': 0.09181636726546906, 'fraction_numerical': 0.003992015968063872, 'mean_word_length': 2.450946643717728, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7482094', 'n_tokens_mistral': 539, 'n_tokens_neox': 530, 'n_words': 160}