Bird
0
0

Identify the error in this SwiftUI modifier chain:

medium📝 Debug Q6 of 15
iOS Swift - SwiftUI Basics
Identify the error in this SwiftUI modifier chain:
Text("Hello")
  .font(.headline)
  .foregroundColor = .blue
  .padding()
AMissing parentheses after font modifier
BText view cannot have multiple modifiers
CPadding modifier should come before foregroundColor
DUsing = instead of chaining method call for foregroundColor
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax for chaining modifiers

    Modifiers are chained by calling methods with dot notation, not by assignment with =.
  2. Step 2: Identify incorrect line

    The line .foregroundColor = .blue uses assignment instead of chaining method call .foregroundColor(.blue).
  3. Final Answer:

    Using = instead of chaining method call for foregroundColor -> Option D
  4. Quick Check:

    Modifiers use method calls, not assignments [OK]
Quick Trick: Use dot method calls, not =, for modifiers [OK]
Common Mistakes:
  • Using = instead of parentheses
  • Misordering modifiers (not an error)
  • Thinking multiple modifiers are disallowed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes