iphone - How to start an NSTimer when i click on a button? -


how can start nstimer when user clicks button?

edit:i had code working , everything, put code hide button above nstimer code, , when placed below nstimer code worked!

the line of code start timer (read docs here) :

[nstimer scheduledtimerwithtimeinterval:1.0                                  target:self                                selector:@selector(timerfired:)                                userinfo:nil                                 repeats:nil]; 

this call method timerfired: after 1 second i.e.

- (void)timerfired:(nstimer *)timer {   nslog(@"timer : %@ has gone off", timer); } 

to trigger button, need method in .h file :

- (ibaction)buttonpressed:(id)sender; 

and in .m file, detect button press :

- (ibaction)buttonpressed:(id)sender {   nslog(@"button's been pressed!"); } 

then, in interface builder connect button's 'toiuch inside' action method.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -