简体   繁体   English

AppDelegate.swift使macOS App崩溃

[英]AppDelegate.swift crashes macOS App

When I try to launch my app, it simply crashes. 当我尝试启动我的应用程序时,它只是崩溃了。 The error it gives is unrecognized selector sent to instance 0x608000000ac0 and the error shows up at my AppDelegate.swift file on line 4. Here is the full AppDelegate.swift file: 它给出的错误是unrecognized selector sent to instance 0x608000000ac0并且该错误显示在第4行的AppDelegate.swift文件中。这是完整的AppDelegate.swift文件:

import Cocoa

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate { //This is where I get the error

    @IBOutlet weak var window: NSWindow!

    func applicationDidFinishLaunching(_ aNotification: Notification) {
        // Insert code here to initialize your application
    }

    func applicationWillTerminate(_ aNotification: Notification) {
        // Insert code here to tear down your application
    }

    func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
        return true
    }
}

How do I fix this error? 如何解决此错误? Thanks in advance, Aaronjam 在此先感谢,Aaronjam

After trying to fix the problem for over an hour, I deleted my target (after backing up my code, of course) and made a new one. 在尝试解决了一个多小时的问题后,我删除了目标(当然,在备份我的代码之后)并创建了一个新目标。 Thanks for your help, @OverD! 感谢您的帮助,@ OverD!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM