In traditional imperative UI frameworks, such as UIKit, the developer manually updates the UI by calling specific methods whenever data changes. SwiftUI, however, leverages a declarative model where the framework itself monitors changes in the UI's data model and triggers re-renders automatically. This concept is known as automatic redraws.
It's important to understand that a re-rendering resets our view, even the init
is executed again, so in order to keep the current value of our variables we can use the @State
property wrapper.
This means that we can have regular constants since they won't change their value.
State property wrapper
@State
will be the default property wrapper to use for the values that will change over time. For the values that won't change, we'll use constants:
Continue reading
Access to all the content with our plans.
- Junior level content
- Senior level content
- Expert level content
- Extra content
- Question submissions
Be the first to comment