title: Selectors in SwiftUI
body: <p>I'm trying to use 3rd party libraries that are created for UIKit in SwiftUI, for example, the <code>BetterSegmentedControl</code> library (<a href="https://github.com/gmarm/BetterSegmentedControl" rel="noreferrer">https://github.com/gmarm/BetterSegmentedControl</a>)
  requires a Selector witch takes an <code>objc</code> function to handle users input. </p>
  
  <p>is there even a way of handling this in SwiftUI?</p>
  
  <pre><code>struct ContentView : UIViewRepresentable {
      func makeUIView(context: Context) -&gt; BetterSegmentedControl {
          BetterSegmentedControl()
      }
  
  
      func updateUIView(_ view: BetterSegmentedControl, context: Context) {
          let control = BetterSegmentedControl(
              frame: CGRect(x: 0, y: 0, width: 300, height: 44),
              segments: LabelSegment.segments(withTitles: ["One", "Two", "Three"],
                                              normalTextColor: .lightGray,
                                              selectedTextColor: .white),
              index: 1,
              options: [.backgroundColor(.darkGray),
                        .indicatorViewBackgroundColor(.blue)])
  
          view.addSubview(control)
  
          @objc func controlValueChanged(_ sender: BetterSegmentedControl) {
  
          }
  
          control.addTarget(self, action: #selector(controlValueChanged(_:)), for: .valueChanged)
          view.addSubview(control)
  
      }
  }
  </code></pre>
  
  <p>for this code there are 2 errors:</p>
  
  <pre><code>@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes
  
  
  Argument of '#selector' cannot refer to local function 'controlValueChanged'
  </code></pre>