0 votes
asked in Objective C by (4.2k 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 by (3.1k points)


  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.