Timer, #selector explanation
问题 I need a timer so I used this code: timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(generalKnowledge.method), userInfo: nil, repeats: true) But I do not understand the #selector . I tried multiple times but it doesn't work. 回答1: selector() is where you'd add in the function that you want it to call every timeInterval you set. In your example it's every second. Do bare in mind that in Swift 4 and above, you need to add @objc before a function if you want to call