Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a BuildBlock that combines two results.
Swift
let combined = BuildBlock([1]("Hello"), Text("World"))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using String instead of Text causes a type error.
Using Int or View directly is incorrect here.
✗ Incorrect
The BuildBlock combines views, so we use Text to create a view from a string.
2fill in blank
mediumComplete the code to combine three Text views using BuildBlock.
Swift
let combined = BuildBlock(Text("One"), Text("Two"), [1]("Three"))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using String instead of Text causes errors.
Using Int or View directly is not valid here.
✗ Incorrect
Each element inside BuildBlock must be a view, so Text is used for the third element.
3fill in blank
hardFix the error in the BuildBlock by completing the code.
Swift
let combined = BuildBlock(Text("Swift"), [1]("UI"))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using String instead of Text causes a type mismatch.
Using Int or View directly is invalid.
✗ Incorrect
BuildBlock requires views, so Text must be used to wrap the string "UI".
4fill in blank
hardFill both blanks to create a BuildBlock combining two Text views with modifiers.
Swift
let combined = BuildBlock([1]("Hello").font(.title), [2]("World").foregroundColor(.blue))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using String or View instead of Text causes errors.
Label is not appropriate here.
✗ Incorrect
Both blanks must be Text to create views that can have modifiers like font and foregroundColor.
5fill in blank
hardFill all three blanks to create a BuildBlock combining Text views with different modifiers.
Swift
let combined = BuildBlock([1]("Swift").bold(), [2]("UI").italic(), [3]("Kit"))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using String or View instead of Text causes errors.
Label is not suitable here.
✗ Incorrect
All three blanks must be Text to create views that support modifiers like bold and italic.