Laurent Crivello
Laurent Crivello

Reputation: 3931

applicationDidFinishLaunching not invoked

In my appdelegate.m, the applicationDidFinishLaunching is not invoked. I have read that this is due to the fact my "Application"'s delegate is not properly connected, but I don't know how to connect it. What I do is right-clicking on Application from the XIB file, and drag the delegate outlet somewhere... but don't know where. Any help appreciated. Thanks !

Upvotes: 37

Views: 14148

Answers (2)

original_username
original_username

Reputation: 2399

Here's something to try if you've updated to Swift 3:

Take a peek at your "AppDelegate.swift" and make sure the relevant line looks like this:

func applicationDidFinishLaunching(_ aNotification: Notification) {

as opposed to this:

func applicationDidFinishLaunching(_ aNotification: NSNotification) {

I just updated an app, and didn't think to check. The result was that my app launched, but the relevant method was never called. Obviously, you should then check for other functions you have that take Notification objects.

Upvotes: 5

Joshua Nozzi
Joshua Nozzi

Reputation: 61228

In your MainMenu.xib, make sure there's an instance of your AppDelegate class. To make one, drag a plain object (blue cube) into the list and set its class name to AppDelegate (or whatever your app delegate class name is).

Also in the MainMenu.xib, to connect it, drag a connection from the Application object to your AppDelegate instance (the blue cube) and connect it to the delegate outlet.

Done.

Upvotes: 55

Related Questions