This is my exact code, and it doesn't seem to be working. Can you tell me what I am doing wrong? Note that refreshTimer was already declared in the private interface.
-(void)viewDidLoad {
refreshTimer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(timerTest) userInfo:nil repeats:YES];
}
-(void)timerTest {
NSLog(@"Timer Worked");
}
Give scheduledTimerWithTimeInterval
a try:
NSTimer *myTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(myMethod) userInfo:nil repeats:YES];
Quoting: NSTimer timerWithTimeInterval: not working
scheduledTimerWithTimeInterval:invocation:repeats
: and scheduledTimerWithTimeInterval:target:selector:userInfo:repeats
: create timers that get automatically added to an NSRunLoop
, meaning that you don't have to add them yourself. Having them added to an NSRunLoop
is what causes them to fire.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With