timerWithTimeInterval not getting called

0 votes
61 views
asked Apr 8, 2015 in Objective C by john (4,220 points)

Hi All

   I am using following code to call use the NSTimer, but the timer not calling the function

 [NSTimer timerWithTimeInterval:.01 target:self selector:@selector(changeTileColor) userInfo:nil repeats:YES];

Please help how to solve this issue

 

1 Answer

0 votes
answered Apr 8, 2015 by jonathan (3,105 points)

Hi

  In general we can init NSTimer using the following function

  1. timerWithTimeInterval

  2. scheduledTimerWithTimeInterval

The first function won't create the run loop we should explicitly create run loop.

     [[NSRunLoop currentRunLoop] addTimer:refreshTimer forMode:NSRunLoopCommonModes];

The second function has bundle this feature itself.

...