Bird
0
0

Identify the error in this SwiftUI code snippet:

medium📝 Debug Q14 of 15
iOS Swift - SwiftUI Layout
Identify the error in this SwiftUI code snippet:
Text("Hello")
  .frame(width: 100 height: 50)
Aframe modifier requires alignment parameter
BText cannot use frame modifier
CWidth and height values must be strings
DMissing comma between width and height parameters
Step-by-Step Solution
Solution:
  1. Step 1: Check parameter syntax

    Parameters in SwiftUI modifiers must be separated by commas.
  2. Step 2: Locate the error

    The code misses a comma between width: 100 and height: 50, causing a syntax error.
  3. Final Answer:

    Missing comma between width and height parameters -> Option D
  4. Quick Check:

    Parameters need commas [OK]
Quick Trick: Separate parameters with commas in modifiers [OK]
Common Mistakes:
  • Omitting commas between parameters
  • Thinking frame can't be used on Text
  • Using wrong data types for width/height

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes