3 Replies
      Latest reply on May 5, 2019 4:19 PM by KMT
      knz_toyz Level 1 Level 1 (0 points)

        Newbe creating a mainWindowController.xib. I updated the AppDelegate.swift file as the text book showed but when I try and Run the app I don't get the window that I created. It is like the app isn't ever going into the AppDelegate file.  How can I check to see if the app is even executing the AppDelegate file?  What can I put in the MainMenu.xib that will force the AppDelegate file to be executed?  Thanks

        • Re: AppDelegate.swift not executing
          Claude31 Level 8 Level 8 (6,635 points)

          This is  MacOS App ?

           

          If so, your code should look like:

           

          @NSApplicationMain
          class AppDelegate: NSObject, NSApplicationDelegate {
          
              @IBOutlet weak var window: NSWindow!
          
              func applicationDidFinishLaunching(aNotification: NSNotification) {
                  // Insert code here to initialize your application
              }
          
              func applicationWillTerminate(aNotification: NSNotification) {
                  // Insert code here to tear down your application
              }
          
          }

           

          Then the simplest is to create the window in MainMenu.xib and connect to this IBOutlet.

          • Re: AppDelegate.swift not executing
            knz_toyz Level 1 Level 1 (0 points)

            I found my problem....It was in the AppDelegate.swift file

             

            The book showed "func applicationDidFinishLaunching(aNotification: Notification) {"

             

            Where it should have looked like "func applicationDidFinishLaunching(_ aNotification: Notification) {"

             

            Being a newbe not sure why though.....And yes this was a OSX application.

             

            Thanks for your help