100 Days of SwiftUI Day 87

100 Days of SwiftUI – Day 87

We’ve arrived at day 87 of the 100 Days of SwiftUI! Yesterday, we started the Flashzilla project with at gestures and vibrations. Today, we’re learning how to trigger events using a timer and how to be notified when our SwiftUI app moves to the background. Let’s dive in!

Triggering events repeatedly using a timer

iOS features a built in Timer class. This class allows us to schedule and run code on a regular basis, which uses a system of publishers that comes from an Apple framework called Combine. We can use this functionality to repeatedly run some code at a specific time interval.

How to be notified when your SwiftUI app moves to the background

SwiftUI can detect when your app moves to the background (i.e., when the user returns to the home screen), and when it comes back to the foreground. By detecting this, SwiftUI knows then to pause the app and resume it again. This comes in handy in a lot of instances. For example, just think of a game that automatically pauses when you leave the app. Setting this up takes three steps, and Paul tells you all about it.

Wrap up

That’s it for day 87! We’ll keep moving forward with Flashzilla for the upcoming days, so stay tuned as tomorrow we’ll learn how to build a card view. Until then!


Hi! My name is Darryl and this is my personal blog where I write about my journey as I learn programming! You'll also find articles about other things that interest me including games, tech and anime.

Post navigation

Leave a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

100 Days of SwiftUI – Day 96

100 Days of SwiftUI – Day 29 – Word Scramble

100 Days of SwiftUI – Day 17 – WeSplit

100 Days of SwiftUI – Day 66