Bird
0
0

Identify the error in this SwiftUI code snippet:

medium📝 Debug Q14 of 15
iOS Swift - SwiftUI Basics
Identify the error in this SwiftUI code snippet:
HStack {
  Text("One")
  VStack
  Text("Two")
}
AMissing braces after VStack declaration
BText views cannot be inside HStack
CHStack requires parentheses instead of braces
DVStack cannot be nested inside HStack
Step-by-Step Solution
Solution:
  1. Step 1: Check VStack usage

    VStack is a view container and requires braces { } to enclose child views.
  2. Step 2: Identify missing braces

    Code shows VStack without braces, causing syntax error.
  3. Final Answer:

    Missing braces after VStack declaration -> Option A
  4. Quick Check:

    Containers need braces for children [OK]
Quick Trick: Always add braces after VStack or HStack [OK]
Common Mistakes:
  • Omitting braces for stack containers
  • Thinking Text can't be inside HStack
  • Using parentheses instead of braces for stacks

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes