This is the signature for MIDIObjectGetProperties in Swift:
func MIDIObjectGetProperties(obj: MIDIObjectRef, outProperties: UnsafeMutablePointer<Unmanaged<CFPropertyList>?>, deep: Boolean) -> OSStatus
So you need to pass UnsafeMutablePointer to Unmanaged<CFPropertyList>? :
var midiDevice = MIDIGetDevice(0) var unmanagedProperties: Unmanaged<CFPropertyList>? MIDIObjectGetProperties(midiDevice, &unmanagedProperties, 1)
Now you have your properties, but they are in an unmanaged variable - you can use the takeUnretainedValue() method to pull them out, and then draw the resulting CFPropertyList on an NSDictionary :
if let midiProperties: CFPropertyList = unmanagedProperties?.takeUnretainedValue() { let midiDictionary = midiProperties as NSDictionary println("Midi properties: \(index) \n \(midiDictionary)"); } else { println("Couldn't load properties for \(index)") }
Results:
Midi properties: 0 { "apple.midirtp.errors" = <>; driver = "com.apple.AppleMIDIRTPDriver"; entities = ( ); image = "/Library/Audio/MIDI Drivers/AppleMIDIRTPDriver.plugin/Contents/Resources/RTPDriverIcon.tiff"; manufacturer = ""; model = ""; name = Network; offline = 0; scheduleAheadMuSec = 50000; uniqueID = 442847711; }
source share