title: Swift + iOS: How to call closure from within async call?
body: <p>I have a web view inside of my app. I'm currently looking at each request and seeing if they are a youtube video before allowing / canceling the request:</p>
  
  <pre><code>extension WebBrowserViewController: WKNavigationDelegate {
    func webView(webView: WKWebView, decidePolicyForNavigationAction navigationAction: WKNavigationAction, decisionHandler: (WKNavigationActionPolicy) -&gt; Void) {
      if (urlVideoType(webView.URL!) != VideoUrl.Unknown &amp;&amp; urlVideoType(webView.URL!) != VideoUrl.Youtube) {
        ...
      } else if urlVideoType(webView.URL!) == VideoUrl.Youtube {
        // the success and failure part don't work
        presentYoutubeVideoIfAvailable(webView.URL!, success: decisionHandler(.Cancel), failure: decisionHandler(.Allow)) &lt;-------------------
      } else {
        decisionHandler(.Allow)
      }
    }
  }
  </code></pre>
  
  <p>My <code>presentYoutubeVideoIfAvailable</code> method uses this youtube url parser pod: <a href="https://github.com/movielala/YoutubeSourceParserKit" rel="nofollow">https://github.com/movielala/YoutubeSourceParserKit</a></p>
  
  <p>However, that makes an async call and I don't know how to make it call the success and failure methods in my method:</p>
  
  <pre><code>  func presentYoutubeVideoIfAvailable(url: NSURL, success: (), failure: ()) {
      Youtube.h264videosWithYoutubeURL(url) {  [unowned self] (videoInfo, _) -&gt; Void in
        switch videoInfo?["url"] as? String {
        case .Some(let videoUrlString):
          VideoStore.addVideo(url.absoluteString, title: videoInfo?["title"] as? String ?? "Unknown")
          success
          self.presentVideo(NSURL(string: videoUrlString)!)
        case .None:
          print("herereee") // gets printed, so I know it's here
          failure // doesn't do anything. it should be allowing the request but it isn't &lt;-----------------------------------
          self.showError(.YoutubeParsingFail)
        }
      }
    }
  </code></pre>
  
  <p>I want it so that if the youtube pod returns a url, it should cancel the web view request, and if it fails I want it to continue with the request. How would I do this?</p>