Katkat

Design an iOS Timer App with Consistent State and Asynchronous UI Updates

RobinhoodSoftware Engineer · Technical Screen

Last updated

Design an iOS timer around explicit state transitions, clock-based elapsed time, main-thread UI updates, callback ownership, and lifecycle behavior.

Design and implement the structure of a small iOS timer application, focusing on state management, UI updates, and asynchronous work. Explain how time is represented, how user actions change the state, and how the interface stays consistent as callbacks and app lifecycle events occur.

Constraints

The timer's exact product behavior is unspecified. Clarify whether it is a stopwatch, countdown, or interval timer before implementing it. UIKit or SwiftUI and Swift or Objective-C are acceptable; choose one combination and explain it consistently. This is a platform-specific implementation discussion rather than a portable algorithm console.

Clarifying Questions

  • Which actions are required: start, pause, resume, reset, or setting a duration?
  • Should elapsed time include periods when the app is backgrounded or the device sleeps?
  • Does state need to survive process termination, and is any notification required?
  • How precise must the display be, and what should happen if callbacks are delayed?

Hints

Hint 1

A callback is a refresh opportunity: Count elapsed time using a clock and recorded state rather than assuming every scheduled callback fires exactly on time.

Follow-up questions

  • How would you prevent duplicate timer subscriptions after repeated view appearances?
  • How would a countdown prevent its completion action from firing twice?