Repeating a method every few seconds in Objective C
10,844
The problem is that target
is nil.
What this timer does is every 7 seconds it calls [nil foo]
, which does nothing.
If you want to call the method foo
on the object that creates the timer, use target:self
Related videos on Youtube
Author by
Snowman
Updated on June 12, 2022Comments
-
Snowman almost 2 years
I have a method
-(void)foo
that I want to call once inviewDidAppear
, then I want it to repeat everyn
seconds, wheren
is some integer. How can I do this?I tried this, but it's not repeating:
[NSTimer scheduledTimerWithTimeInterval:7.0 target:nil selector:@selector(foo) userInfo:nil repeats:YES];