[ad_1]
I have 2 functions. The first function can not be expose to objective c as it is a observer of core midi. The second function is visible to objective c so that I can pass data back to React Native.
To pass data between the 2 functions should I be using a struct or global variable.
I need the packet and source from function 1 passed to function 2. when adding @objc to the receive function I get error: Method cannot be marked @objc because the type of the parameter 2 cannot be represented in Objective-C
I figure to just save the data to global variable which works however not sure if I should use global variable or struct or is the whole things being constructed wrong
func receive(_ packet: MIDIPacket, from source: MIDISource) {
switch packet.message {
case .noteOn, .noteOff, .controlChange, .pitchBendChange, .programChange:
sendToReactNative()
default:
break
}
}
@objc
func sendToReactNative(){
var data = ""
sendEvent(withName: "onMidi", body: [data])
}
[ad_2]