Build a SwiftUI Custom Countdown Timer app for iOS 15 (2022)

  Рет қаралды 14,153

Indently

2 жыл бұрын

In today's video we will be looking at how we can create a custom countdown timer app with SwiftUI in Xcode. We will be using the MVVM architecture pattern to achieve the simple functionality of this app.
There's a lot of functionality that can be added, but it's also important that you work on that as a challenge!
00:00 App Demo
01:26 New Project
01:36 ViewModel
09:14 UI
15:08 Running the app
Source code: github.com/federicocotogno/CustomCountdownTimer

Пікірлер: 31
@Some1Something
@Some1Something 2 жыл бұрын
Thanks for your videos. Im planning to start learning swift soon. In the mean time, I watch your tutorials to prime myself.
@francoishofer9254
@francoishofer9254 Жыл бұрын
Thanks so much your explanations! Simple and clear
@user-wq2fw2ke1d
@user-wq2fw2ke1d 6 ай бұрын
Thanks for your video. I've discovered many projects and watched several videos today.Your project handling of background timers is the best.
@Indently
@Indently 6 ай бұрын
Glad it was helpful!
@acjazz01
@acjazz01 4 ай бұрын
I gave up using this SwiftUI Timer because I need more than one clock in two popup views, and it just stops working when both are running simultaneously. I rewrote the code using the old and good Timer from Swift and it just works!
@nnzrmn
@nnzrmn 11 ай бұрын
Super helpful!
@laurentbennis
@laurentbennis 4 ай бұрын
That was awesome ta much !
@calmchucknorris910
@calmchucknorris910 2 жыл бұрын
Awesome work man! I was wondering how would you implement milliseconds in the timer?
@mobiledevicerepairs2897
@mobiledevicerepairs2897 2 жыл бұрын
Great video. Would you also be able to add another countdown timer to run independently to the one you've made in this video? I have made a countdown timer using the Swift Guy video but my main timer gets affected when adding and using another timer in the same view controller. Thanks.
@jesusfortuna6850
@jesusfortuna6850 2 жыл бұрын
Great video, How would you do it if you want to implement N timers? I have an app and it's already using a similar solution, but when I use more than 4 timers they don't behave ok. Hope you can help me out
@santiagolimas2014
@santiagolimas2014 Жыл бұрын
Thanks! One question, how would you pause and resume the timer?
@leonstone3443
@leonstone3443 Жыл бұрын
maybe you can help steer me in the right direction, every video is for iOS, how much of a difference would this be to make for like the menu bar on my mac? Can you even make new icons and small apps for the menu bar?
@experienciasusuario6892
@experienciasusuario6892 Жыл бұрын
I have a question.. For example: if I have one list with 10 elements and I need that each element has one timer, it is possible? I comment because the idea is to do a Tickets App such as a Restaurant. @Indently
@xderiwx
@xderiwx 2 жыл бұрын
Thanks for the tutorial! If you wanted to do something along the lines of a boxing timer, where you have a countdown like you do here, but also a second countdown for the rest period between rounds after the first countdown ends, would you need to terminate the original countdown before resuming? Any tips on what I would need to look into to accomplish that? Thanks!
@kierankowalski4659
@kierankowalski4659 2 жыл бұрын
Did you have any problems on generating the preview? If so what was it and how did you fix it? I‘ve seen to run into a roadblock. Thanks!
@xderiwx
@xderiwx 2 жыл бұрын
@@kierankowalski4659 My Previews worked. What kind of issue do you have?
@kierankowalski4659
@kierankowalski4659 2 жыл бұрын
@@xderiwx A lot. Total of 91. I can list them all if you want.
@kierankowalski4659
@kierankowalski4659 2 жыл бұрын
@@xderiwx Nevermind, thanks for your help. It seems that it‘s a problem with the system.
@Unnosed
@Unnosed 8 ай бұрын
hello, im not sure if i'll get a quick reply but i really need one and would apprecite it... how can i make the countdown timer to be in hours, minutes and secons? and for it to be displayed as 00:00:00
@kierankowalski4659
@kierankowalski4659 2 жыл бұрын
Hi, I copied the ViewModel code correctly but it‘s still telling me that I have errors. I double checked that the code was correct. It says there are 91 errors, the three big main categories being „Swift Compiler Error“, „Uncategorized“, and „Error“. Does anyone have any tips?
@Indently
@Indently 2 жыл бұрын
You can try closing and opening Xcode again, or else you need to check all the code to see if you copied it correctly.
@kierankowalski4659
@kierankowalski4659 2 жыл бұрын
@@Indently I tried that, but it still didn‘t work. It says the problems are in other categories that we didn‘t touch.
@jasneersingh8683
@jasneersingh8683 Жыл бұрын
Hi, I copied the code exactly but when I press start, it shows a timer of 30mins with the addition of the set time. It acts like normal but it shows 30 mins. Is there something I did wrong?
@NewbieBallerz
@NewbieBallerz Жыл бұрын
same here
@user-zv8ob7xf8i
@user-zv8ob7xf8i Жыл бұрын
@@NewbieBallerz unc formatTime (date: Date) -> String { let formatter = DateFormatter() formatter.dateFormat = "mm:ss" formatter.timeZone = NSTimeZone(name: "UTC") as TimeZone? let formattedDate = formatter.string(from: date) return formattedDate } use this to get string from date.
@shukhor3010
@shukhor3010 Жыл бұрын
Not sure why my countdown string format %d%02d always gave me 30:00, I not sure where the 3 came from??
@user-zv8ob7xf8i
@user-zv8ob7xf8i Жыл бұрын
func formatTime (date: Date) -> String { let formatter = DateFormatter() formatter.dateFormat = "mm:ss" formatter.timeZone = NSTimeZone(name: "UTC") as TimeZone? let formattedDate = formatter.string(from: date) return formattedDate } use this to get string from date.
@ajainajmi9
@ajainajmi9 4 ай бұрын
@@user-zv8ob7xf8iwhere should i put this function?
@SOMEBODY692
@SOMEBODY692 8 ай бұрын
hi
@usher-p
@usher-p Жыл бұрын
how do you consider this a proper video? your timer literally moves around!
@yourgflikesit
@yourgflikesit Жыл бұрын
Yeah, but can I keep running in the background
КАК ДУМАЕТЕ КТО ВЫЙГРАЕТ😂
00:29
МЯТНАЯ ФАНТА
Рет қаралды 10 МЛН
ЧУТЬ НЕ УТОНУЛ #shorts
00:27
Паша Осадчий
Рет қаралды 10 МЛН
Задержи дыхание дольше всех!
00:42
Аришнев
Рет қаралды 3,7 МЛН
КАК ДУМАЕТЕ КТО ВЫЙГРАЕТ😂
00:29
МЯТНАЯ ФАНТА
Рет қаралды 10 МЛН