wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

SwiftUI Test

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What is SwiftUI primarily used for?

a)

Developing console applications

b)

Creating user interfaces for Apple platforms

c)

Managing databases

d)

Web development

2.

Which syntax does SwiftUI use to simplify UI code?

a)

Imperative Syntax

b)

Declarative Syntax

c)

Procedural Syntax

d)

Object-Oriented Syntax

3.

Which of the following is NOT a feature of SwiftUI?

a)

Live Preview

b)

Cross-platform Development

c)

Built-in Accessibility

d)

Integrated Database Management

4.

How can SwiftUI views be customised for different device orientations?

a)

Using CSS

b)

Using VStack and HStack

c)

Using SQL Queries

d)

Using External Libraries

5.

When would you use the @Binding property wrapper in SwiftUI?

a)

To declare a state variable that only the current view needs to track.

b)

To create a one-way data flow from a parent view to a child view.

c)

To establish a two-way data connection between a parent and a child view.

d)

To pass environment values down the view hierarchy.

6.

In SwiftUI, how is a vertical stack of views created?

a)

ZStack

b)

HStack

c)

VStack

d)

StackView

7.

What is the purpose of the @ObservedObject property wrapper?

a)

To observe and respond to SQL database changes

b)

To create observable objects that can be used for state management

c)

To observe changes in a web service

d)

To monitor and react to hardware sensor data

8.

Which SwiftUI element is used to navigate between views?

a)

NavigationLink

b)

Button

c)

Redirect

d)

Hyperlink

9.

How do you add a shadow to a text view in SwiftUI?

a)

Using the .shadow() modifier

b)

Applying a CSS class

c)

Using the .border() modifier

d)

Implementing a shadow protocol

10.

What does the @EnvironmentObject property wrapper do?

a)

Sets up a new environmental variable

b)

Injects dependency objects into the view hierarchy

c)

Changes the app's theme based on the user's system settings

d)

Manages global settings for the SwiftUI application

11.

Which SwiftUI structure is used to define a reusable component?

a)

Func

b)

Class

c)

Struct

d)

Enum

12.

What is the primary use of a ViewBuilder in SwiftUI?

a)

To create a reactive data flow between different parts of your UI.

b)

To define a method that returns a custom view with a dynamic number of child views.

c)

To simplify the management of state in complex view hierarchies.

d)

To optimize the rendering performance of complex UI components.

13.

How can you apply an implicit animation to a view in SwiftUI?

a)

By wrapping the view update code inside a withAnimation block.

b)

By directly modifying the view's properties without using an animation block.

c)

By using .animation() modifier on a view.

d)

By setting an @State variable with a custom animation object.

14.

Which control would you use in SwiftUI to allow users to pick a value from a list of options?

a)

Slider

b)

TextField

c)

Picker

d)

Button

15.

Which SwiftUI layout container allows for overlapping content?

a)

ZStack

b)

UIStackView

c)

VStack

d)

HSTack

16.

Which SwiftUI concept is essential for sharing data across multiple views without passing it explicitly?

a)

EnvironmentObject

b)

Data Passing

c)

DataStream

d)

@SharedData property wrapper

17.

How do you localise text in a SwiftUI app for multiple languages?

a)

Using the @Localise property wrapper

b)

Implementing a translation API

c)

Direct translation within the code

d)

Using the Localisable.strings file

18.

What SwiftUI view is used to create a scrollable list of items?

a)

UITableView

b)

VStack

c)

ScrollView

d)

ListView

19.

In SwiftUI, what does the @State property wrapper do?

a)

It manages complex object states across multiple views.

b)

It declares a source of truth for a value within a view that triggers UI updates when the value changes.

c)

It binds data between a parent and a child view.

d)

It observes an object’s properties for changes and updates the UI accordingly.

20.

How would you push some content, e.g a VStack to the top of a view if it is not where you want it?

a)

alignment: .top

b)

alignment: .leading

c)

alignment: .trailing

d)

Spacer()