My timer not getting repeated please help
here is the code
timer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(doAnimation:) userInfo:nil repeats:YES];
[timer fire];
method
-(void)doAnimation:(id)Sender
{
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
[timer fire]manually fires the timer only once and is not actually “starting” the timer. From the docs:You need to add the timer in a run loop before it will start firing and repeating:
An easier way would be to do something like:
and:
This automatically schedules the timer and adds it to the run loop. Just in case you aren’t doing it, as you have set the target to be
selfyou have to make sure the methoddoAnimationis defined within the same class.NSTimer Class Reference