Simple Popup - problem display View Controller

Hi Experts,


I'm really new in swift development for OS X. I made some some small projects in order to teach my self. But now I got a problem and I have no idea what is wrong:


1) I created a new Cocoa Application and added a button to initial view controller. In the action of the button I will open a popup.

2) Than I created in storyboard a new WindowController.

3) Created a new cocoa class ( Subclass NSWindowController) including XIB file and changed the class of the new added window to this created class.

3) Created a new cocoa class ( Subclass NSViewController) including XIB file and changed the class of the new added view Controller to this created class.

4) added a label to this new view Controller


in my MainViewController I added this:

I created a global var: let mwc = WindowPopup(windowNibName: "WindowPopup")


and call this in the action: mwc.window!.orderFront(self)


So far so good, my window was open :-). But the label will not be displayed. I don't know why. Does anyone have an idea, how to solve my problem?


Thanks in advance Stefan

Hi,


I'm not expert but I can try to help,


Did you try to use segues to do what your trying to do.


If you use the storyboard, it's the easyest way to do this.


1 create a cocoa app and make sure use storyboard is checked


2 go in the storyboard a drag a button on the view under the Window of your app.


3 add a new Viewcontroller on the storyboard (not a window controller)


4 add a cocoa file to your project name it as you want, (MyViewController) and make it to be a NSViewController sub class object. Make sure that you uncheck the Make the xnib (you don't need it, you've already done this in step 3)


5 return to the storyboard and select the new ViewController you made and on the right, assign the newly class you've juste create (MyViewController). So if you want to had some programming code, it will be associate with you view


6 On the stroyboard, drag un new label on the new ViewController


7 On the first view of your app, Control Drag from the button to the new viewController, then you'll be able to choose want way you want to show this view. (sheet, modal, popover and custom)


8 build and run your app and it should be ok if there is no error.


Hoping my english is not too bad, and this is only the beginning of great work to come.


iFrancky

In addition, you may search for Ray Wanderlich mew site where there is a lot of cool tutorials, and they are very well explain and easy to follow.

Simple Popup - problem display View Controller
 
 
Q