Is it possible to initialize an nstimer a certain number of times without having to set the timer as a property? The reason I want this is because I am constantly allocating new timers at certain periods in my application and so I can’t use a property because once i invalidate the property timer it cant be used anymore.
in the [NSTimer scheduledTimerWithTimeInterval: target:selector: userInfo:nil repeats:] method can i use the target parameter to pass in the timer itself as a parameter in the selector i specify? (sorry, i don’t really no what the target thing means in the method).
if that doesn’t work could I maybe try the [NSTimer scheduledTimerWithTimeInterval: invocation: repeats:] and use the invocation property to help me do this or something? Sorry I don’t know what the invocation parameter in this method is either, I looked at the documentation but I still don’t understand.
“target” for a timer means the object you want to run the selector (or method, or action) on.
And the best way to keep track of how many times you run a timer would be to instantiate some custom Objective C object which has a “counter” or “number of times run” property (or ivar) and then increment it each time the timer runs the method off of that object.
As soon as the counter passes the number of times you desire, you can invalidate the timer (which is passed in as a parameter to whatever method that you call) and release the custom object.