title: How to implement C-Style callback functions using swift?
body: <p>I found an example for <code>IOKit</code>:</p>
  
  <pre><code>var notification:io_object_t
  
  let matching:NSDictionary = IOServiceNameMatching("IODisplayWrangler").takeRetainedValue()
  let displayWrangler = IOServiceGetMatchingService(kIOMasterPortDefault, matching)
  let notificationPort = IONotificationPortCreate(kIOMasterPortDefault)
      IOServiceAddInterestNotification(notificationPort, displayWrangler, kIOGeneralInterest, displayPowerNotificationsCallback, nil, &amp;notification)
  
  CFRunLoopAddSource (CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(notificationPort), kCFRunLoopDefaultMode);
     IOObjectRelease (displayWrangler);
  </code></pre>
  
  <p>The above example is clear to me - so far. But <code>IOServiceAddInteresNotification</code> wants a callback function. In  it's simple to do this, by implementing the C-Style function somewhere in the <code>.m</code>-file. </p>
  
  <p>The documentation says that I have to use a callback of type <code>IOServiceInterestCallback</code>.</p>
  
  <p>In C-Style it is defined as follows:</p>
  
  <pre><code>typedef void ( *IOServiceInterestCallback)( void *refcon, io_service_t service, uint32_t messageType, void *messageArgument );
  </code></pre>
  
  <p>And on objC everything seems to work out perfectly. 
  What is the equivalent solution in swift? How do I declare the callback function without creating a C or objC file for this?</p>
  
  <p>Any ideas?</p>
  
  <p>Cheers,</p>
  
  <p>Jack</p>