SwiftUI Flashcards

1
Q

UIViewRepresentable

A

A protocol used as a wrapper for a UIKit view that you use to integrate that view into your SwiftUI view.

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

The two methods required for conforming to UIViewRepresentable

A

makeUIView(context: Context) -> MKMapView

updateUIView(_ uiView: MKMapView, context: Context)

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

What is needed to communicate between a UIView that conforms to UIViewRepresentable and SwiftUI

A
class Coordinator: NSObject, MKMapViewDelegate { }
makeCoordinator() -> Coordinator
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Define @binding

A

Use a binding to create a two-way connection between a property that stores data and a view that displays and changes the data.

It creates a 2 way binding for the data. So one view can create the data while many other views can read and update that same data.

it lets us declare that one value actually comes from elsewhere, and should be shared in both places.

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

What’s the purpose @Environment(\.presentationMode) var presentationMode and how do you use it.

A

A binding to the current presentation mode of the view associated with this environment.

It allows you to close a sheet with self.presentationMode.wrappedValue.dismiss()

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

Define @EnvironmentObject

A

A property wrapper type for an observable object supplied by a parent or ancestor view.

we can place an object into the environment so that any child view can automatically have access to it.

.environmentObject(user)

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