Michael Grant

Michael Grant

SwiftUI class notes 2022-01-23

Still working on getting my head wrapped around UIViewRepresentable and UIViewControllerRepresentable. A pair of YouTube videos from Nick Sarno (Swiftful Thinking) is offers a helpful different perspective from Paul Hudson’s material that I’ve mostly been following.

Not sure I quite get the concept of “context”.

Elements of a UIViewRepresentable struct:

  • @Binding var — data being passed between the representable UIView and the parent SwiftUI view
  • Coordinator class and func makeCoordinator() -> Coordinator
  • func makeUIView(context: Context) -> some UIView
  • func updateUIView(_ uiView: UIViewType, context: Context)

Open questions:

  • ¿Does every UIView and UIViewController subclass have its own delegate protocol?
  • ¿What’s the self._text thing about?