我知道我应该像arbitraryAction()
而不是arbitraryAction(_ complition: (() -> Void)?)
那样实现选择器。只看下面的代码。如果您点击Button,代码将随机崩溃,这使我发疯。我只想知道为什么崩溃是随机的!
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let button = UIButton.init(frame: CGRect.init(x: 100, y: 100, width: 100, height: 100))
button.backgroundColor = .red
button.addTarget(self, action: #selector(self.arbitraryAction(_:)), for: .touchUpInside)
view.addSubview(button)
}
@objc func arbitraryAction(_ complition: (() -> Void)?) {
}
}