FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
Building a Precision Timer in SwiftUI Without Drift
How-ToProgramming Languages

Building a Precision Timer in SwiftUI Without Drift

via Dev.togarry4h ago

The Problem With Naive Timers When I started building BoxTime, my boxing round timer app, I made the classic mistake: I used Timer.scheduledTimer with a 1-second interval and decremented a counter. It looked right in the simulator. It looked right for the first 30 seconds on a real device. Then the drift crept in. After a 3-minute round, my timer was off by 1-2 seconds. Over a full 12-round session, that adds up. In boxing, timing matters. You can't have a round timer that lies to you. Why Timers Drift The fundamental issue is that Timer in iOS is not a precision instrument. It fires on the run loop, and the run loop has other things to do. Each tick might be 1.002 seconds instead of 1.000. Those fractions accumulate. // The naive approach - DO NOT use this for precision Timer . scheduledTimer ( withTimeInterval : 1.0 , repeats : true ) { _ in self . remainingSeconds -= 1 } The run loop might delay a fire by milliseconds. When the UI is busy, it gets worse. Scrolling, animations, hapti

Continue reading on Dev.to

Opens in a new tab

Read Full Article
3 views

Related Articles

Developer Leave Planning: How to Handoff Projects Before FMLA Starts
How-To

Developer Leave Planning: How to Handoff Projects Before FMLA Starts

Dev.to • 4h ago

Engineering Principles for Life, Not Just for Code
How-To

Engineering Principles for Life, Not Just for Code

Medium Programming • 4h ago

Best Laptops (2026): My Honest Advice Having Tested Hundreds
How-To

Best Laptops (2026): My Honest Advice Having Tested Hundreds

Wired • 5h ago

GE Profile Smart Grind and Brew Review: Just the Basics
How-To

GE Profile Smart Grind and Brew Review: Just the Basics

Wired • 7h ago

How I Would Learn Data Engineering in 2026 If I Started From Zero
How-To

How I Would Learn Data Engineering in 2026 If I Started From Zero

Medium Programming • 11h ago

Discover More Articles