Timer example using NSTimer

April 10, 2009 § Leave a comment

header file .h:

@interface mainView {

NSTimer *timer;

}

@property(nonatomic, retain) NSTimer *timer;
@end

Source file .m:

-(void) applicationDidFinishLaunching : (UIApplication *) application {
timer = [NSTimer scheduledTimerWithInterval: 1.0 target:self selector:@selector(myMethod:) userInfo:nil repeats: YES];
}

//define the myMethod
-(void) myMethod: NSTimer * timer {
NSLog(@”1 sec passed”);
}

@end

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

What’s this?

You are currently reading Timer example using NSTimer at Web Builders.

meta

%d bloggers like this: