calling method repeatedly after 3 seconds time interval in background

Vizllx picture Vizllx · Mar 5, 2014 · Viewed 8.7k times · Source

I have gone through many sites but still no answer.

I have a method suppose void xyz(), which will get called automatically from a View Controller after every 3 seconds.

I have no idea what to use, do I have to use NSThread or PerformSelector.

Answer

Gajendra Rawat picture Gajendra Rawat · Mar 5, 2014

Call this method from ViewDidLoad method.ViewDidLoad will when your view will be appear in iPhone device or Simulator.

[NSTimer scheduledTimerWithTimeInterval:3.0f target:self selector:@selector(runMethod) userInfo:nil repeats:YES];


    -(void)runMethod

    {

    }