我想知道如何关闭或退出我的应用程序?我有一些关闭应用程序的代码,但这些代码看起来不够现代化和更新到SwiftUI,我们有更好的新代码吗?
import SwiftUI
@main
struct Work_Space_macOSApp: App {
var body: some Scene {
WindowGroup {
VStack {
Button("Close App") {
// Do we have more SwifUI-ish code for closing App?
NSApplication.shared.keyWindow?.close()
}
Button("Quit App") {
// How can I quit the app?
}
}
.frame(width: 200, height: 200)
}
}
}