Post

Replies

Boosts

Views

Activity

Reply to Using CABTMIDILocalPeripheralViewController with SwiftUI
UIViewControllerRepresentable SwiftUI MIDI Bluetooth example Content View: @State private var btScan = false @State private var btAdvertise = false var body: some View { VStack { Button("Bluetooth MIDI Scan") { self.btScan = true } .sheet(isPresented: $btScan) { BTConnectController(btScan: self.$btScan) } Button("Bluetooth Advertise") { self.btAdvertise = true } .sheet(isPresented: $btAdvertise) { BTPeripheralController(btAdvertise: self.$btAdvertise) } } .padding() } struct BTConnectController : UIViewControllerRepresentable { func makeUIViewController(context: Context) -> CABTMIDICentralViewController { CABTMIDICentralViewController() } func updateUIViewController(_ uiViewController: CABTMIDICentralViewController, context: Context) { } typealias UIViewControllerType = CABTMIDICentralViewController @Binding var btScan: Bool } struct BTPeripheralController : UIViewControllerRepresentable { func makeUIViewController(context: Context) -> CABTMIDILocalPeripheralViewController { CABTMIDILocalPeripheralViewController() } func updateUIViewController(_ uiViewController: CABTMIDILocalPeripheralViewController, context: Context) { } typealias UIViewControllerType = CABTMIDILocalPeripheralViewController @Binding var btAdvertise: Bool } Hope it helps, @JSE98 Best regards Andreas
Jun ’23
Reply to How to optimize the performance of Share Extension?
Maybe it does not work. Then how to quit Share Extension after its operation finished? The "returningItems" parameters are referring to the output object(s), including any changes written to it. If this doesn't apply to your extension and you want to exit cleanly, just return "nil": self.extensionContext!.completeRequest(returningItems: nil, completionHandler: nil) Andreas
Oct ’22