Chatar Veer Suthar
Chatar Veer Suthar

Reputation: 15639

I want to call a method after particular time until my app opened in iphone?

I want to call a method after each 2 minutes, how can I apply such logic?

Upvotes: 0

Views: 456

Answers (3)

jaggi
jaggi

Reputation: 19

I use a NSTimer to trigger a method. I use the below code in my initial viewDidLoad section:

myTimer = [NSTimer scheduledTimerWithTimeInterval:120.0 target:self selector:@selector(theMethod) userInfo:nil repeats:YES];

Hope that helps.

Upvotes: 0

Krishnabhadra
Krishnabhadra

Reputation: 34275

You can use a timer..

[NSTimer scheduledTimerWithTimeInterval:120.0 target:self selector:@selector(yourFunction:) userInfo:nil repeats:YES];
.........
..........

-(void)yourFunction:(NSTimer*)timer{
//do your action here
}

Upvotes: 2

Sherm Pendley
Sherm Pendley

Reputation: 13612

Use an NSTimer object. It's been talked about quite a lot here, so I won't repeat all that - just search for "NSTimer" in the search box at the top right. :-)

Upvotes: 4

Related Questions