I have a Swift class that I'd like to look something like this:
class UpdateManager {
let timer: NSTimer
init() {
timer = NSTimer(timeInterval: 600, target: self, selector: "check", userInfo: nil, repeats: true)
}
func check() {
// Do some stuff
}
}
However, Swift doesn't like the fact that I'm passing self
to the NSTimer
initializer. Am I breaking some pattern here? How is one supposed to accomplish initialization like this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…