AppDelegate.swift not executing

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

Replies

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.

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

>I found my problem - The book


If you mean an actual dead tree edition, odds are you're looking at gothic swift while working with post modern, aka Swift 5.