applicationDidFinishLaunching未调用,使用storyboards和swift3

时间:2017-02-26 18:23:55

标签: cocoa swift3 xcode-storyboard

运行我的应用时未调用local::lib

这是我applicationDidFinishLaunching班的代码:

AppDelegate

我正在为我的应用使用 Swift 3 storyboards

applicationDidFinishLaunching - not triggering的答案建议将@NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { let statusItem = NSStatusBar.system().statusItem(withLength: NSSquareStatusItemLength) func applicationDidFinishLaunching(_ aNotification: Notification) { // Insert code here to initialize your application } func applicationWillTerminate(_ aNotification: Notification) { // Insert code here to tear down your application } } 连接到故事板中的应用程序对象。我那里没有任何应用程序对象。

我的应用程序没有主菜单,它是代理商,因为我正在尝试构建与聚光灯类似的东西。

如何让AppDelegate.swift运行?

1 个答案:

答案 0 :(得分:6)

即使您的应用程序作为代理运行,您的故事板也应该具有以下结构:

enter image description here

如果没有,将蓝色立方体(对象)拖到应用程序场景中,将对象的类设置为AppDelegate,然后从Application进行控制拖动,再到App Delegate并选择{{ 1}}。

如果您甚至没有应用程序场景,请创建一个启用了故事板的新项目,删除当前的Main.storyboard文件并将新创建的项目的Main.storyboard拖到当前项目中。

相关问题