My app draws a timer (with detail to .1 seconds), for which I am currently using a NSTime which fires every .1 seconds. This feels like an absolutely terrible idea, but I’m not sure how else to do it. I don’t really care about the .1 seconds updating always, but I would like it to update more than once per second. Is there a good way to do this?
Share
NSTimerdoesn’t strike me as a bad approach.NSTimeris generally a very regular way to keep track of time (indeed it was used for animation timing beforeCADisplayLinkcame along). Unless you are seeing unacceptable performance of your timer display updating, I would stick with this approach.If you are having issues with delays and inaccurate time readings, you could store the start time in
NSDate, and continue to use theNSTimerbut only to update the display. On each timer event firing, you then update the display by finding the NSTimeInterval from the start time to now. This way even if there is a performance issue, at least the time being display should remain accurate at the time of display.