@selector() in Swift?

后端 未结 23 2591
清酒与你
清酒与你 2020-11-21 15:24

I\'m trying to create an NSTimer in Swift but I\'m having some trouble.

NSTimer(timeInterval: 1, target: self, selector: test(), us         


        
23条回答
  •  忘掉有多难
    2020-11-21 16:15

    Swift 4.0

    you create the Selector like below.

    1.add the event to a button like:

    button.addTarget(self, action: #selector(clickedButton(sender:)), for: UIControlEvents.touchUpInside)
    

    and the function will be like below:

    @objc func clickedButton(sender: AnyObject) {
    
    }
    

提交回复
热议问题