timer in iOS not working
I have this code for a repeated timer in my app:
(inside viewDidAppear)
NSDate *date = [NSDate dateWithTimeIntervalSinceNow: 3];
NSTimer *restrictionTimer = [[NSTimer alloc] initWithFireDate: date
interval: 3
target: self
selector:@selector(changeRestriction)
userInfo:nil repeats:YES];
and
- (void) changeRestriction
{
NSLog(@"inside !!");
}
Ho开发者_如何转开发wever, I dont see any output, any help ?
If you're using -initWithFireDate:..
you have to manually add the timer to the NSRunLoop. However you could just use +scheduledTimerWithTimeInterval:..
and it will automatically trigger.
精彩评论