title: swift closure stored and access as a variable
body: <p>I want to implement a callback in a swift project just like I used to do in Objective-C
  I need a variable of type closure. That closure should take as a parameter an object and return nothing.</p>
  
  <pre><code>var downloadCompleted: (MLBook) -&gt; (Void)!
  </code></pre>
  
  <p>When I need to trigger the callback I do this:</p>
  
  <pre><code>if self.downloadCompleted {
     self.downloadCompleted(book)
  }
  </code></pre>
  
  <p>The compiler complains with this error message:</p>
  
  <pre><code> Type '(MLBook) -&gt; (Void)!' does not conform to protocol 'BooleanType'
  </code></pre>
  
  <p>If I remove the if statement the compiler says:</p>
  
  <pre><code>Property 'self.downloadCompleted' not initialized
  </code></pre>
  
  <p>even though it's implicitly unwrapped.</p>
  
  <p>When I try to get the callback:</p>
  
  <pre><code>BookStore.sharedInstance.downloadCompleted{(book: MLBook) -&gt; () in
     println("Print if you got the callback")
  }
  </code></pre>
  
  <p>I get this error message:</p>
  
  <pre><code>'(MLBook) -&gt; ()' is not convertible to 'MLBook'
  </code></pre>
  
  <p>I'm more worried about the last error message as I'm not quite sure what it is trying to tell me.</p>
  
  <p>Any help would be appreciated. Thanks</p>