title: Comparing ViewController to a type in swift
body: <pre><code>extension UIViewController {
      func getChildViewController&lt;T&gt;(OfType: T) {
          let classType = Mirror(reflecting: self.childViewControllers.first).subjectType
  
          if classType == T.self {
              print("there is a match")
          }
      }
  }
  </code></pre>
  
  <p>This is an extension to UIViewController, and when you call this function, you pass it a type for example:</p>
  
  <pre><code>ViewController.getChildViewController(OfType: SecondViewController.self)
  </code></pre>
  
  <p>This will check if the first child of view controller if of type SecondViewController</p>
  
  <p>But in the if statement I am getting the error:</p>
  
  <pre><code>Binary operator '==' cannot be applied to operands of type 'Any.Type' and 'T'
  </code></pre>