SimpleBoilerplates / SwiftUI-Cheat-Sheet

SwiftUI 2.0 Cheat Sheet
MIT License
4.37k stars 305 forks source link

SuperVillainViewController example #8

Open avi-kik opened 5 years ago

avi-kik commented 5 years ago

The example does not seem correct. At no point are you instantiating a view controller, as the line

let vc = SuperVillainViewController()

is just creating an instance of the enclosing struct.

Sadmansamee commented 5 years ago

Check https://developer.apple.com/tutorials/swiftui/interfacing-with-uikit and https://dev.to/kevinmaarek/working-with-your-uiviewcontroller-and-swiftui-2917

and this is how it works :) will close this issue.

avi-kik commented 5 years ago

The tutorial makes my point for me. In it, PageViewController is a struct, and it creates a UIPageViewController. In your example, SuperVillainViewController is being used as both the struct and the view controller type.