Learn Courses My Dashboard

Creating a count down timer

I want to create a countdown timer in my app similar to the timer functionality in the Clock app on iOS. Can someone please give me pointers on how to do that ?

@awartika

Welcome to the Code Crew community.

Are you using the SwiftUI framework or UIKit (storyboard)?

For SwiftUI, this article may help:
https://www.hackingwithswift.com/quick-start/swiftui/how-to-use-a-timer-with-swiftui

For a UIKit application this article may help:

1 Like

I am using UIKit framework. My question was more from the UI perspective, creating the timer, adding, reset and stop buttons and when the timer fires, ringing a tone just like the iOS timer in Clock App

From the UI perspective I assume you mean how would you layout the objects (Picker, Buttons and Labels) that make up the UI and then how would you connect those objects up?

Yes. That’s right.

Does that mean you are fairly new to UIKit and storyboard?

Yes I am fairly new but not a complete beginner. If I have some sample code I can figure it out. I know Objective C and Swift fairly well. I just haven’t done the UI programming

Hey @awartika how’s your countdown timer project going?

Thanks for checking. I have found a few tutorials online that I am looking at however I want a play a sound when the timer fires. None of the tutorials have that. If you have any sample code that mimics the functionality of the timer in the clock app, please let me know.

Can you make it change text or print something special when the timer fires?
Can you play sounds at all?

Can you show any code? Use the 3 backticks ` with no spaces on a line by itself before and after your code.

like this

I figured out how to do that when the App is opened, but not while using for example another app, guess that would not help would it?

This might help:

But i dont know if this is what u want tho