title: Accessing Array of View Controllers on Stack in Swift
body: <p>Basically I'm trying to do this in Swift</p>
  
  <pre><code>// get the Detail view controller in our UISplitViewController (nil if not in one)
  id detail = self.splitViewController.viewControllers[1];
  // if Detail is a UINavigationController, look at its root view controller to find it
  if ([detail isKindOfClass:[UINavigationController class]]) {
      detail = [((UINavigationController *)detail).viewControllers firstObject];
  }
  </code></pre>
  
  <p>I've got as far as this;</p>
  
  <pre><code>var detail : AnyObject = self.splitViewController.viewControllers[1]
  
      if detail.isKindOfClass(UINavigationController) {
          detail = ((detail: UINavigationController).detail).
  </code></pre>
  
  <p>but I can't find what to do after this.</p>
  
  <p>Another separate quick question.  Is it considered good practice to have a lot of statements ending in <code>as [type]</code>.  It's mainly resulting from the use of AnyObject's, like using valueForKeyPath for instance.  It just seems a bit messy having it all over my code </p>