我有一个类Person被多次实例化。每个人都有自己的计时器。当我在init
为Person
我打电话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)")
}
...
...
}
因此,我可能在的数组中有3个Person实例Person[]
。我收到一个错误:
2014-06-25 13:57:14.956 ThisProgram[3842:148856] *** NSForwarding: warning: object 0x113760048 of class '_TtC11ThisProgram6Person' does not implement methodSignatureForSelector: -- trouble ahead
我在其他地方读过我应该继承的内容,NSObject
但这是在Swift中而不是Obj-C中。该函数在该类中,因此我不确定该怎么做。
class Person : NSObject { ... }
。您在寻找其他解决方案吗?