Action to a button programmatically

import UIKit

import PlaygroundSupport

class btnAction {

@objc func action(sender: UIButton!){

print("button tapped")

}

}

let view = UIView(frame: CGRect(x: 0, y: 0, width: 500, height: 500))

view.backgroundColor = UIColor.white

let btn = UIButton()

btn.setTitle("hello", for: .normal)

btn.addTarget(btnAction.self, action: #selector(btnAction.action), for: .touchUpInside)

view.addSubview(btn)

PlaygroundPage.current.liveView = view


I use this code to add action to my button. But in the live view, this never works. I only see a white view. why does this happen?

Thanks in advance.