0

I'm trying to use DiskArbitration and install a first callback function, which is DADiskAppearedCallback, but i am stuck at the DARegisterDiskAppearedCallback statement, with this error:

'DeviceManager' is not convertible to 'UnsafeMutablePointer<()>'

I need to pass a DeviceManager instance to the callback in order to populate the array inside...

Here is my code:

class DeviceManager {
  var devices = [Device]()

  func diskAppearedCallback(disk: DADisk!, context: UnsafeMutablePointer<()>) {
    NSLog("Disk: \(DADiskGetBSDName(disk))")

    // Create and Add a device here...     
  }

  var callback = CFunctionPointer<(DADisk!, UnsafeMutablePointer<()>) -> Void>()

  init() {

    var session = DASessionCreate(kCFAllocatorDefault).takeRetainedValue()    

    DARegisterDiskAppearedCallback(session, kDADiskDescriptionMatchVolumeMountable, callback, self) 

    ...      

  }
}

Thank's in advance for any help.

mugx
  • 9,869
  • 3
  • 43
  • 55
  • any reason why context is `UnsafeMutablePointer<()>`? – Bryan Chen Aug 28 '14 at 00:05
  • possible duplicate of [Using Swift CFunctionPointer to pass a callback to CoreMIDI API](http://stackoverflow.com/questions/25514176/using-swift-cfunctionpointer-to-pass-a-callback-to-coremidi-api) – rickster Aug 28 '14 at 01:54

0 Answers0