在使用以下代码运行应用程序时,有时会出现错误代码:
let letstryOtherThing: @convention(c) (UnsafeMutablePointer<MIDISysexSendRequest>) -> Swift.Void =
{ plop in
print("here")
}
let rawPointer = UnsafeRawPointer([0xF0, 0x20, 0x21, 0x22, 0x23, 0xF7])
let pointer = rawPointer.assumingMemoryBound(to: UInt8.self)
let bytesToSend: UInt32 = 60
let complete: DarwinBoolean = false
let completionProc: MIDICompletionProc? = letstryOtherThing
let completionRefCon: UnsafeMutableRawPointer? = nil
let data: UnsafePointer<UInt8> = pointer
let destination: MIDIEndpointRef = dest!
let reserved: (UInt8, UInt8, UInt8) = (0, 0 ,0)
var midiRequest:MIDISysexSendRequest = MIDISysexSendRequest(destination: destination, data: data, bytesToSend: bytesToSend, complete: complete, reserved: reserved, completionProc: completionProc!, completionRefCon: completionRefCon)
DispatchQueue.main.async(execute: {
MIDISendSysex(&midiRequest)
})守则是:
EXC_BAD_ACCESS (code=1,address=0x800000020)。
如果有人有想法的话,我会使用CoreMidi库。
发布于 2017-10-31 13:24:52
我发现了问题。这是因为这个var是本地的,在全局中声明它是必要的。
var midiRequest:MIDISysexSendRequest = MIDISysexSendRequest(destination: destination, data: data, bytesToSend: bytesToSend, complete: complete, reserved: reserved, completionProc: completionProc!, completionRefCon: completionRefCon)https://stackoverflow.com/questions/47017150
复制相似问题