tags:

views:

244

answers:

1

The documentation says about timerWithTimeInterval:target:selector:userInfo:repeats:

Returns a new NSTimer that, when added to a run loop, will fire after a specified number of seconds.

I don't fully understand this. Maybe someone can tell if it fires immediately or if the first time the selector gets called would be after the specified time interval (i.e. 10 seconds)?

+1  A: 

It will fire in the given timeInterval, so not immediately. And when you set repeats to NO, it will not fire itself again, otherwise, it will send the first message after timeInterval seconds, then every timeInterval seconds.

JoostK
thanks. What would be an option to fire immediately but still have an interval following? I guess I would just call the selector. But that could probably cause collisions on whery tight intervals, right?
HelloMoon
I don't know if performSelector: will work just as a static message in code, so whether or not the method gets pushed on the stack and executed immediately, as normal, but I think it will. Maybe you don't even need performSelector: and call the message straight.
JoostK
ah, yeah that's what I actually tried to say. Calling the method (which is specified as selector) just directly.
HelloMoon