Bird
0
0

What is the main purpose of the @State property wrapper in SwiftUI?

easy📝 Conceptual Q11 of 15
iOS Swift - State Management in SwiftUI
What is the main purpose of the @State property wrapper in SwiftUI?
ATo keep track of data that can change and update the UI automatically
BTo create a constant value that never changes
CTo store data permanently on the device
DTo define a function inside a view
Step-by-Step Solution
Solution:
  1. Step 1: Understand @State role

    @State is used to hold data that can change inside a SwiftUI view.
  2. Step 2: Connect data change to UI update

    When @State data changes, SwiftUI automatically refreshes the view to show the new data.
  3. Final Answer:

    To keep track of data that can change and update the UI automatically -> Option A
  4. Quick Check:

    @State updates UI on data change = B [OK]
Quick Trick: Remember: @State means data changes update the screen [OK]
Common Mistakes:
  • Thinking @State stores permanent data
  • Confusing @State with constants
  • Using @State for functions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes