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:
Text("Hello")
  .font(.title)
  .padding(10, 20)
APadding modifier does not accept two numbers like that
BText view cannot have modifiers chained
CFont modifier .title is invalid
DPadding modifier requires only one argument
Step-by-Step Solution
Solution:
  1. Step 1: Check padding modifier syntax

    The .padding() modifier accepts either no arguments, one argument for uniform padding, or a specific edge set with length.
  2. Step 2: Analyze given arguments

    Passing two numbers directly like .padding(10, 20) is invalid syntax in SwiftUI.
  3. Final Answer:

    Padding modifier does not accept two numbers like that -> Option A
  4. Quick Check:

    .padding() needs one argument or edge set [OK]
Quick Trick: Padding takes one value or edges + value [OK]
Common Mistakes:
  • Passing multiple numbers directly to padding
  • Confusing padding with frame size
  • Assuming .title font is invalid

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes