xcode - Objective-C, Displaying an NSTimer activated by a UIButton -


I am working on a project for school that includes a set of buttons used as a countdown timer Given NStimers will ideally be displayed in the title of the timer's UIButton as the title.

So far, I am only able to do this work, while setting the display of time, instead of passing a UIButton logic, instead of passing a specific example of UIButton, I declare "time" NSString Which has the current display value calculated by NSTimer. It is not how the final implementation should be, and I have set it only to work partially.

Code for one of the buttons:

  b1 = [[UIButton alloc] initWithFrame: CGRectMake (neutral.frame.size.width * 0.56, neutral.frame. Size.heat * 0.18, neutral.frame.height * 0.64, neutral .frame.height.height * 0.64]]; [B1.titleLabel setFont: [UIFont fontWithName: @ "helvetica-bold" Size: 35.0]]; [B1 setbackground image: forState: UIControlStateNormal];  

The process of pressing the button by method:

  - Clicked the button (id): (ID) sender {// do stuff timer = [ NSTimer Scheduled Timer With Time Interval: 1 Goal: Self Selector: @Selector (TimerFide) User Ink: [With NSNM Number Number: T] Repeats: Yes]; }  

NSTimer timer removed method:

  - (zero) timerfide {if ((curmin> 0? Cursec = = 0 ) & Amp; amp; Curmin> = 0) {if (curSec == 0) {curMin- = 1; CurSec = 59; } And if (curSec> 0) {curSec- = 1; } If (curnain-gt; -1) {time = [NSString stringWithFormat: @ "% d% @% 02d", Kariman, @ ":", Corse]; [B1 SETITAL: STATE FOR TIME: UCentralStateAnimal]; }} And {{B1} Satyttah: Neil for State: UIControllstate honoral]; [Invalid timer]; }}  

I hope what I am trying to do to fulfill this. I am somewhat surprised that I can not find anything to walk through this medium. I'm flexible to change how it works. It really matters that each button can start a unique countdown timer.

I'm sure the code is muddy, but the purpose is relatively new to me, so any help would be appreciated.

Do not store time as minutes / second, just seconds Use, as all more than 60 arguments are really tedious, is not it?

I have chosen to call the frequency variable _secondsLeft so I know that this means that when I look at the code in 6 months time:

  - (zero) timerfield {NSString * formatted = @ ""; If (secondslift> gt; {secs} -; Formatted = [NSString stringWithFormat: @ "% d:% 02d", (SecondLight / 60), (SecondLight% 60)]; } Other {[invalid timer]; } [B1Setital: State for Formats: UIContolstadtAnimal]; }  

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -