Tenho uma classe Person que é instanciada várias vezes. Cada pessoa tem seu próprio cronômetro. Em cima do meu initpara Personeu chamo startTimer().
class Person {
var timer = NSTimer()
func startTimer() {
timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("timerTick"), userInfo: nil, repeats: true)
}
func timerTick() {
angerLevel++
println("Angry! \(angerLevel)")
}
...
...
}
Portanto, posso ter 3 instâncias de Person em uma matriz de Person[]. Estou recebendo um erro:
2014-06-25 13:57:14.956 ThisProgram[3842:148856] *** NSForwarding: warning: object 0x113760048 of class '_TtC11ThisProgram6Person' does not implement methodSignatureForSelector: -- trouble ahead
Li em outro lugar que deveria herdar, NSObjectmas isso está em Swift, não em Obj-C. A função é dentro da classe, então não tenho certeza do que fazer.
class Person : NSObject { ... }. Você está procurando uma solução diferente?