title: How do I set the default tab for tab bar controller in swift
body: <p>I'm new to Swift, and about a 5 out of 10 on the <strong>Objective-C</strong> knowledge scale.. </p>
  
  <p>I created a basic three tab Swift application. Each tab has an associated swift class file, e.g. <strong>FirstViewController.swift</strong> , <strong>SecondViewController.swift</strong>, <strong>ThirdViewController.swift</strong>.</p>
  
  <p>When I select the third tab, I now open the application preference settings using a <code>viewDidAppear</code> function override in <strong>ThirdViewController.swift</strong>, e.g.:</p>
  
  <pre><code>override func viewDidAppear(animated: Bool) {
      // open app preference s
      if let url = NSURL(string:UIApplicationOpenSettingsURLString) {
          UIApplication.sharedApplication().openURL(url)
      }
  }
  </code></pre>
  
  <p>Though, prior to opening the preferences, I would like to set the active tab back to the first tab. How is this done elegantly in Swift.</p>
  
  <p>The following does not work:</p>
  
  <pre><code>self.tabBarController.selectedIndex = 0
  </code></pre>
  
  <p>As the <code>UIViewController</code> of the <strong>ThirdViewController</strong> class does not have a <code>tabBarController</code>.</p>
  
  <p>Brian.</p>