When I migrate a Swift 3 app to the 4 Xcode asked me to add @objc
in front of a couple of my function.
And when I did it show me a warning that "@objc is deprecated"
I was wondering if there is any better solution for handling addTarget
in Swift 4?
Here is my UIButton :
let playButton: UIButton = {
let btn = UIButton(type: .system)
btn.setTitle("Play", for: .normal)
btn.setTitleColor(.green, for: .normal)
btn.addTarget(self, action: #selector(playTapped), for: .touchUpInside)
return btn
}()
func :
@objc func playTapped() {
let path = AudioPlayerManager.shared.audioFileInUserDocuments(name: "test")
AudioPlayerManager.shared.playAudio(path: path)
}
it possible to add action to the button without using #selector
and `@objc'?
Thanks.