title: Instantiate UIStoryboard at runtime in Swift2, how to handle failure?
body: <p>I am trying to load a UIStoryboard dynamically, based on some runtime condition in my app (and then instantiate the view controllers within)</p>
  
  <p>Since the method <code>UIStoryboard(name: bundle:)</code> totally looks like it could fail (i.e., wrong file name, not found in bundle, etc.) I was under the assumption that it returns an optional of type <code>UIStoryboard?</code>. However, writing this code:</p>
  
  <pre><code>if let storyboard = UIStoryboard(name: "", bundle: nil) as? UIStoryboard{
      // Use the storyboard...   
  }
  </code></pre>
  
  <p>...gives the warning:</p>
  
  <blockquote>
    <p>Conditional cast from 'UIStoryboard' to 'UIStoryboard' always succeeds</p>
  </blockquote>
  
  <p>Because it is an initializer, the method signature in the inline documentation (option-click over the method's <code>name:</code> label) does not list a return type.</p>
  
  <p>The actual web page for the documentation (pre-release, <a href="https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIStoryboard_Class/index.html#//apple_ref/occ/clm/UIStoryboard/storyboardWithName:bundle:" rel="nofollow">here</a>) says:</p>
  
  <blockquote>
    <p>Return Value </p>
    
    <p>A storyboard object for the specified file. If no
    storyboard resource file matching name exists, <strong>an exception is thrown</strong>
    with description: Could not find a storyboard named 'XXXXXX' in
    bundle....</p>
  </blockquote>
  
  <p>(emphasis mine). However, attempting the do-try-catch approach gives me the warning:</p>
  
  <blockquote>
    <p>No calls to throwing functions occur within 'try' expression</p>
  </blockquote>
  
  <p>So, how am I supposed to handle failure?</p>