我有一个计时器调用一个方法,但这种方法需要一个paramether方法:如何将参数传递给一个名为在的NSTimer
theTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(timer) userInfo:nil repeats:YES];
应该
theTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(timer:game) userInfo:nil repeats:YES];
现在这个语法没有按” t似乎是正确的。我试着用NSInvocation的,但我得到了一些问题:
timerInvocation = [NSInvocation invocationWithMethodSignature:
[self methodSignatureForSelector:@selector(timer:game)]];
theTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval
invocation:timerInvocation
repeats:YES];
我应该如何使用调用?
如果您需要传递几个对象,那就是要走的路。但如果它只是一个单一的对象,你不需要将它封装到字典中。 – DarkDust 2011-03-02 10:45:15
是的。我刚刚看到通知使用userInfo字典,所以认为保持一致性。 – Eimantas 2011-03-02 10:58:32