Call method every 5 minutes in my UIView

I want to call a specific method in my UIView code, say every 5 minutes - how to do this?

+4
source share
3 answers

You can use NSTimer:

Put in your viewDidLoad (where 300 is the number of seconds):

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

And then create your update method:

 - (void)updateMethod:(NSTimer *)theTimer { // Your code goes here } 
+12
source

You can use NSTimer for this.

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSTimer_Class/Reference/NSTimer.html

In particular, timerWithTimeInterval:target:selector:userInfo:repeats: class.

+2
source

There is an easy way to do this, in your update method

 -(void)update{ //Your update methods here [self performSelector:@selector(update) withObject:nil afterDelay:300.0]; } 
0
source

All Articles