0

I'm developing a MacOSX app and I don't know how to change the main window created by AppDelegate by another created by me in another ViewController. Actually I instantiate the viewController and set the main view to the AppDelegate window content view, but I want to change this in order to show only another window I have in the ViewController XIB, how can I do this?

Here is my XIB structure and AppDelegate content:

func applicationDidFinishLaunching(aNotification: NSNotification) {
    // Insert code here to initialize your application

    mainController = MainController(nibName: "MainController", bundle: nil)

    //window.contentView!.addSubview(mainController.view)
    //mainController.view.frame = (window.contentView! as NSView).bounds

    window = mainController.mainWindow

    //Setiing MOC to MainController:
    //mainController.managedObjectContext = self.managedObjectContext

}

As you can see I tried to set the AppDelegate Window to my ViewController Window but it show nothing, maybe is because the controller is not created yet?

Thanks for all :).

ViewController Window I only want to have

  • If you only want one view, why not make it the view that's shown in the default window? – Phillip Mills Jan 08 '16 at 13:13
  • First of all thanks for reply :)! That's because I have some controls than need to be linked with the NSViewController such as Cocoa Binding Actions... – Juandisims Jan 08 '16 at 13:33
  • Well you can't just replace a window by setting a property. I would create MainController's view as the default view in your default window in IB. Then drag an NSObject and drop it into your Objects on the left in IB. Set that new object to be MainController. And then just set MainController's view property to the view you created. – rocky Jan 12 '16 at 00:53

0 Answers0