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 !
2 Answers
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.

- 60,946
- 14
- 140
- 135
-
7You saved me a lot of time, thanks ! In addition to that I had to link it to the File Owner. – Laurent Crivello Oct 28 '11 at 19:07
-
1The conceptual hurtle to leap is understanding a nib/xib is a collection of *instances* of freeze-dried objects. In a running app, there's usually only one of each of the major architectural elements like your NSApp instance and its delegate. Document controller/view assemblies are the obvious exception but even then, a separate "document" prototype xib contains one object representing the doc instance, a main window, etc. You don't, however, include a pre-baked instance of a model object in a xib (like a Person), since this is variable (there's usually no one Person). Key concepts. :-) – Joshua Nozzi Oct 28 '11 at 19:36
-
1Thanks for this! I already spent a day trying to figure out why my login helper stopped working all the sudden. I accidentally deleted and later created a new MainMenu.xib – Tibidabo Apr 07 '14 at 08:02
-
5In Xcode 6 (haven't tested earlier), it seems only the File Owner needs to be linked, not Application object. – cortices May 16 '15 at 07:42
-
3File's Owner is indeed the Application in MainMenu.nib files. – Joshua Nozzi Oct 07 '15 at 17:38
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.

- 2,398
- 20
- 24
-
Thank you, this was what fixed my problem, coming from a Swift 2 app. – Thomas Pritchard Dec 04 '17 at 11:42
-