Bird
0
0

Why does the searchable modifier require a binding to a state variable instead of a simple string?

hard📝 Conceptual Q10 of 15
iOS Swift - Lists and Data Display
Why does the searchable modifier require a binding to a state variable instead of a simple string?
ABecause it only works with @Published properties
BBecause strings cannot be passed to modifiers
CBecause bindings improve performance by caching strings
DBecause it needs to update the UI dynamically as the user types
Step-by-Step Solution
Solution:
  1. Step 1: Understand dynamic UI updates

    The search bar updates the UI as the user types, so it needs a binding to a state variable to reflect changes live.
  2. Step 2: Clarify why simple strings don't work

    Simple strings are immutable values and do not notify the UI of changes, so they cannot drive dynamic updates.
  3. Final Answer:

    Because it needs to update the UI dynamically as the user types -> Option D
  4. Quick Check:

    Binding enables live UI updates [OK]
Quick Trick: Binding allows UI to update as user types [OK]
Common Mistakes:
  • Thinking strings can't be passed to modifiers
  • Confusing bindings with performance caching
  • Assuming only @Published works with searchable

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes