@selector() in Swift?

后端 未结 23 2543
清酒与你
清酒与你 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:07

    For swift 3

    let timer = Timer.scheduledTimer(timeInterval: 0.01, target: self, selector: #selector(self.test), userInfo: nil, repeats: true)
    

    Function declaration In same class:

    @objc func test()
    {
        // my function
    } 
    

提交回复
热议问题