Lecture 1: Intro to SwiftUI Flashcards

1
Q

What is the framework/package we must import for any SwiftUI functionality to work? (Full syntax)

A

import SwiftUI

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a Struct?

A

A data structure

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

In SwiftUI, what must any Struct that wants to act as a view contain?

A

It must declare a variable, body, which acts as a view.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What do we call a variable which is declared within a struct?

A

A property. It is a property of the struct it is declared within.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the syntax to create a Struct of type View, named ContentView in SwiftUI?

A

struct ContentView: View {}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the syntax to create the body variable (view) within this struct?

A

var body: some View {}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

If we declare a var body of type ‘some View’, what must this variable/function return?

A

It must return something of type view. In SwiftUI this could be Text(“”), Image(UIImage…” etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the syntax to create our struct view, with our body var, and have it return the text “Hello, World!”?

A

import SwiftUI

struct ContentView: View {
var body: some View {
Text("Hello, World")
}
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly