title: Swift: passing a C Function (SCNetworkReachabilityCallBack)
body: <p>I'm trying to call <code>SCNetworkReachabilitySetCallback</code> the second parameter of which is <code>SCNetworkReachabilityCallBack</code></p>
  
  <p>In the Swiftified <code>SCNetworkReachability.h</code>, this is defined as:</p>
  
  <p><code>typealias SCNetworkReachabilityCallBack = CFunctionPointer&lt;((SCNetworkReachability!, SCNetworkReachabilityFlags, UnsafeMutablePointer&lt;Void&gt;) -&gt; Void)&gt;</code></p>
  
  <p>In Objective-C, I'd declare a function like:</p>
  
  <pre><code>static void MYReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info) {
      // do something
  }
  </code></pre>
  
  <p>and pass this as a parameter. I'n Swift it seems that I should be passing a closure with the signature defined in <code>SCNetworkReachabilityCallBack</code>, something like this:</p>
  
  <pre><code>let callback = { (target: SCNetworkReachability!, flags: SCNetworkReachabilityFlags, info: UnsafeMutablePointer&lt;Void&gt;) in
      // Do something
  }
  </code></pre>
  
  <p>but this gives the error:</p>
  
  <blockquote>
    <p>Cannot convert the expression's type '(SCNetworkReachability!,
    SCNetworkReachabilityFlags, UnsafeMutablePointer) ->
    (SCNetworkReachability!, SCNetworkReachabilityFlags,
    UnsafeMutablePointer) -> $T0' to type '(SCNetworkReachability!,
    SCNetworkReachabilityFlags, UnsafeMutablePointer) ->
    (SCNetworkReachability!, SCNetworkReachabilityFlags,
    UnsafeMutablePointer) -> $T0'</p>
  </blockquote>
  
  <p>which is somewhat puzzling!</p>
  
  <p>Has anyone else come across this problem or has a solution?</p>