iOS Timer Selector with argument

updateTimer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(updateTable:) userInfo:[NSDictionary dictionaryWithObject:indexPath forKey:@"idx"] repeats:YES];


   
- (void)updateTable:(NSTimer *)timer
{
   NSIndexPath *indexPath = [[timer userInfo] objectForKey:@"idx"];
   Clock *currentCell = [timerListData objectAtIndex:indexPath.row];

   NSLog(@"idx:%d",indexPath.row);
   
   [myTableView reloadData];
}



cancel a timer
[timer invalidate];
timer = nil;

0 意見: