xcode 未调用 applicationDidFinishLaunching
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7921407/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
applicationDidFinishLaunching not invoked
提问by Laurent Crivello
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 !
在我的 appdelegate.m 中,没有调用 applicationDidFinishLaunching。我读到这是因为我的“应用程序”的委托没有正确连接,但我不知道如何连接它。我所做的是右键单击 XIB 文件中的应用程序,然后将委托出口拖到某处……但不知道在哪里。任何帮助表示赞赏。谢谢 !
回答by Joshua Nozzi
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).
在 MainMenu.xib 中,确保有一个 AppDelegate 类的实例。要制作一个,将一个普通对象(蓝色立方体)拖到列表中并将其类名设置为 AppDelegate(或任何您的应用程序委托类名)。
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.
同样在 MainMenu.xib 中,要连接它,请将连接从 Application 对象拖到您的 AppDelegate 实例(蓝色立方体)并将其连接到委托插座。
Done.
完毕。
回答by original_username
Here's something to try if you've updated to Swift 3:
如果您已更新到 Swift 3,可以尝试以下方法:
Take a peek at your "AppDelegate.swift" and make sure the relevant line looks like this:
看一看你的“AppDelegate.swift”并确保相关行看起来像这样:
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.
我刚刚更新了一个应用程序,没想到要检查。结果是我的应用程序启动了,但相关方法从未被调用。显然,然后您应该检查您拥有的其他接受 Notification 对象的函数。