Hi,
Trying to display a view controller in playground from a nib, but not having much luck. I’ve seen demos where people create a subclass of UIViewController, and inside the “loadView” method, they manually create views. What I’m trying to do is just to setup the viewcontroller (and its views) inside a nib and just load that, and display it in the playground.
So the xib file has a view controller in it, which has a view by default (that’s the result of dragging a view controller object into the xib in IB). The xib file is added to the “Resources” folder inside the playground.
I compile the xib file at the terminal using ibtool --compile MyViewController.nib MyViewController.xib
.
I have a swift file added to the playground’s “Sources” folder. The swift file is called the same way as the xib/nib files “MyViewController”.
Inside the swift file is my class definition, which is pretty much nothing but an empty class declaration class MyViewController: UIViewController {}
Then, in the playground file I’m initing my viewcontroller from the nib file:
PlaygroundPage.current.liveView = vc```
This is giving me the error: "loaded the "MyViewController" nib but the view outlet was not set"
I don't know how to set the outlets, since it's not possible to drag and drop or assign outlets to/from a nib within a playground.
Any ideas how to do this? Thank you.