<commit_before>//
//  UIViewController+RGAppTools.swift
//  RGAppTools
//
//  Created by RAIN on 2017/8/16.
//  Copyright © 2017年 Smartech. All rights reserved.
//

import UIKit<commit_msg>feat (UIViewController) : add a method<commit_after>//
//  UIViewController+RGAppTools.swift
//  RGAppTools
//
//  Created by RAIN on 2017/8/16.
//  Copyright © 2017年 Smartech. All rights reserved.
//

import UIKit

extension RGAppTools where Base: UIViewController {
    /// 获取位于最上层的视图
    public var topViewController: UIViewController {
        if base is UITabBarController {
            let tabBarController = base as! UITabBarController
            return tabBarController.selectedViewController!.rat.topViewController
        } else if base is UINavigationController {
            let navigationController = base as! UINavigationController
            return navigationController.visibleViewController!.rat.topViewController
        } else if let presentedViewController = base.presentedViewController {
            return presentedViewController.rat.topViewController
        } else {
            return base
        }
    }
}
{'fraction_non_alphanumeric': 0.07658058771148708, 'fraction_numerical': 0.019590382902938557, 'mean_word_length': 2.7972972972972974, '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': '3958082', 'n_tokens_mistral': 333, 'n_tokens_neox': 293, 'n_words': 80}