How to use NSTIMER in IOS Programatically ?

////sample.h
#import <UIKit/UIKit.h>
@interface sample : UIViewController
{
NSTimer *timer_time_taken;
}
@property (nonatomic, retain) NSTimer *timer_time_taken;
@end

///sample.m

#import “sample.h”
@implementation sample

– (void)viewDidLoad
{
[super viewDidLoad];

timer_time_taken = [NSTimer scheduledTimerWithTimeInterval:(1.0) target:self selector:@selector(time_taken_Ticker) userInfo:nil repeats:YES];

}

-(void)time_taken_Ticker
{

NSLog(@”Timer=%d”,[mysingleton sharedInstance].timer_seconds);
time_taken_lbl.text=[NSString stringWithFormat:@”Time:%02d:%02d”,minute,second];
}

@end

Scroll to Top

Discover more from CODE t!ps

Subscribe now to keep reading and get access to the full archive.

Continue reading