I am trying to subclass a NSViewController as a part of my application. I can get equivalent code to work in an iOS playground but something about the way MacOS does things causes things not to work.
I was hoping that this code:
import AppKit
import PlaygroundSupport
class PVC: NSViewController {
var textField: NSTextField?
override func loadView() {
print("Loading view")
self.view = NSView() /
}
override func viewDidLoad() {
super.viewDidLoad()
print("did load")
textField = NSTextField(frame: NSRect(x: 10, y: 10, width: 100, height: 100))
textField!.isBezeled = false
textField!.drawsBackground = false
textField!.isEditable = false
textField!.isSelectable = false
textField!.stringValue = "TEST"
self.view.addSubview(textField!)
}
}
let vc = PVC()
PlaygroundPage.current.liveView = vc
Would cause my view controller to be displayed in the live view however it is just blank although no errors are generated. Both print statements are printed.
Why is this not working?