title: Get class name of UIViewController in swift
body: <p>How do you get the class name of a <code>UIViewController</code> class in Swift?</p>
  <p>In Objective-C, we can do something like this:</p>
  <pre><code>self.appDelegate = (shAppDelegate *)[[UIApplication sharedApplication] delegate];
      UIViewController *last_screen = self.appDelegate.popScreens.lastObject ;
      
      if(last_screen.class != self.navigationController.visibleViewController.class){
  
      //.......
  }
  </code></pre>
  <p>but in Swift I tried:</p>
  <pre><code>let appDelegate = UIApplication.sharedApplication().delegate as AppDelegate
      let last_screen = appDelegate.popScreens?.lastObject as UIViewController
  </code></pre>
  <p>Can't do this.</p>
  <pre><code>if last_screen.class != self.navigationController.visibleViewController.class {
  
  //....
  
  }
  </code></pre>
  <p>no <code>class</code> method of <code>UIViewController</code> i.e last screen</p>