Reputation: 15639
I want to call a method after each 2 minutes, how can I apply such logic?
Upvotes: 0
Views: 456
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
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
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