0

I have a window in the storyboard and a box in defined a xib file. I would like to see the box appearing on the window as soon as the app launches.

The box is also defined by a custom cocoa class that I created and I associated to the xib file. The class is called Box.

Why does the code in the picture doesn't show the box in the window? The code is in the NSViewController of the window. Thank you

Matt
  • 773
  • 2
  • 15
  • 32

1 Answers1

1

Try to replace window.addSubview(box) with self.view.addSubview(box).
You need to display your view as a subview of your root view controller.

Quentin Hayot
  • 7,786
  • 6
  • 45
  • 62
  • This works pretty good if the object to be shown is a NSTextField for example, but not for my object Box(). There's something missing! Maybe a connection between the xib file and the Box class. The custom class of the View in the xib file is the Box class for sure but it's not enough maybe. – Matt Jun 11 '15 at 10:43
  • It works great, I couldn't fine the answer! thanks a lot – Matt Jun 11 '15 at 17:05