Bird
0
0

Which of the following is the correct syntax to create a LazyVStack with three Text views labeled "One", "Two", and "Three"?

easy📝 Syntax Q3 of 15
iOS Swift - SwiftUI Layout
Which of the following is the correct syntax to create a LazyVStack with three Text views labeled "One", "Two", and "Three"?
ALazyVStack { Text("One"), Text("Two"), Text("Three") }
BLazyVStack { Text("One") Text("Two") Text("Three") }
CLazyVStack(Text("One"), Text("Two"), Text("Three"))
DLazyVStack([Text("One"), Text("Two"), Text("Three")])
Step-by-Step Solution
Solution:
  1. Step 1: Recall LazyVStack syntax

    LazyVStack uses a trailing closure with child views listed inside curly braces.
  2. Step 2: Check each option

    LazyVStack { Text("One") Text("Two") Text("Three") } correctly uses braces and separates views by new lines. The option using commas between Text views is invalid syntax for SwiftUI view builders. Array syntax and passing views as direct parameters use incorrect initializer syntax.
  3. Final Answer:

    LazyVStack { Text("One") Text("Two") Text("Three") } -> Option B
  4. Quick Check:

    Trailing closure syntax = LazyVStack { Text("One") Text("Two") Text("Three") } [OK]
Quick Trick: Use braces and list views inside for LazyVStack [OK]
Common Mistakes:
  • Using array syntax inside LazyVStack
  • Passing views as parameters instead of closure
  • Using commas between views in view builder

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes