问题
My problem is simple, but tricky. I want to write this line
AUPreset *aPreset = (AUPreset*)CFArrayGetValueAtIndex(mEQPresetsArray, indexPath.row);
in Swift. The trick is that the return value is UnsafePointer<Void>
.
回答1:
Have you tried this?:
let aPreset = UnsafePointer<AUPreset>(CFArrayGetValueAtIndex(mEQPresetsArray, indexPath.row))
回答2:
Here's the Swift 4 version
let aPreset = unsafeBitCast(CFArrayGetValueAtIndex(mEQPresetsArray, indexPath), to: AUPreset.self)
来源:https://stackoverflow.com/questions/38475249/using-cfarraygetvalueatindex-in-swift-with-unsafepointer-aupreset