Bird
0
0

Which of the following is the correct syntax to add a searchable modifier with a placeholder text?

easy📝 Syntax Q3 of 15
iOS Swift - Lists and Data Display
Which of the following is the correct syntax to add a searchable modifier with a placeholder text?
A.searchable(text: searchText, hint: "Search items")
B.searchable($searchText, placeholder: "Search items")
C.searchable(text: $searchText, prompt: "Search items")
D.searchable(text: $searchText, placeholder: "Search items")
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct parameter names

    The searchable modifier uses prompt to set placeholder text, not placeholder or hint.
  2. Step 2: Confirm binding and prompt usage

    The correct syntax is .searchable(text: $searchText, prompt: "Search items").
  3. Final Answer:

    .searchable(text: $searchText, prompt: "Search items") -> Option C
  4. Quick Check:

    Placeholder uses prompt parameter [OK]
Quick Trick: Use prompt: for placeholder text in searchable [OK]
Common Mistakes:
  • Using placeholder or hint instead of prompt
  • Not binding the search text
  • Passing searchText without $

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes