ios - How do you show a timer in objective-c as a label on screen? -


In this game, I am slowly developing, there is currently a label that updates (counter ++) each click . I no longer want the amount of clicks that appear in this label, but I want a second timer from the first click. I have made a bunch of different methods researched online, but I can not get any of them to work.

Make an example of NSTimer

  @interface YourViewController () { NSTimer Stopwatch Timer; NSDate * startDateTime; }  

Then when your button just opens the timer and looks like a startup

  if (! [StopWatchTimer isValid]) {startDateTime = [NSDate date]; StopWatchTimer = [NSTimer Scheduled Timer WithTime Timeline: 1.0 / 10.0 Target: Self Selector: @Selector (Stopwatch readings) userInfo: Zero repeats: Yes]; }  

Finally implement the StopWatchReading method

  - (zero) stopwatch readings {NSDT * currentdate = [NSDT date]; NSTEEInternewelTimeInterval = [existing date time interlacing date: startdate]; NSDT * TimerDate = [Date of NSDT with Interval: 1970: Time Interval]; // Create date format NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init]; [DateFormatter setDateFormat: @ "HH: mm: SS"]; [DateFormat SettimeJohn: [Nationymazone TimezoneForceSecondFMMT: 0.0]]; NSString * timeStr = [dateFormatter stringFromDate: timerDate]; // Set the text to your label [self.myTimerLabel setText: timeStr]; }  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -