Mam klasę Person, której instancja jest uruchamiana wiele razy. Każda osoba ma swój własny licznik czasu. Po w moim initdla Personzadzwonię 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)")
}
...
...
}
Więc mogę mieć 3 wystąpienia Person w tablicy Person[]. Otrzymuję błąd:
2014-06-25 13:57:14.956 ThisProgram[3842:148856] *** NSForwarding: warning: object 0x113760048 of class '_TtC11ThisProgram6Person' does not implement methodSignatureForSelector: -- trouble ahead
Czytałem gdzie indziej, po czym powinienem dziedziczyć, NSObjectale to jest w języku Swift, a nie Obj-C. Funkcja znajduje się w klasie, więc nie wiem, co robić.
class Person : NSObject { ... }. Szukasz innego rozwiązania?