Hello:
I am creating a Menu Bar Extra Item for my MAC os App. I have the following code but nothing displays on the menu bar. W ould appreciate some advice on where in the code I need to make changes:
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
//@IBOutlet weak var window: NSWindow!
let statusItem = NSStatusBar.system.statusItem(withLength:NSStatusItem.squareLength)
// var item: NSStatusItem? = nil
@objc func QuitScorCentMasterReview(_ sender: Any?) {
NSApplication.shared.terminate(self)
}
func applicationDidFinishLaunching(_ aNotification: Notification) {
if let button = statusItem.button {
button.image = NSImage(named:NSImage.Name("SMR_icon.png"))
button.action = #selector(QuitScorCentMasterReview(_:))
}
func constructMenu() {
let menu = NSMenu()
menu.addItem(NSMenuItem(title: "End the Application", action: #selector(NSApplication.terminate(_:)), keyEquivalent: ""))
statusItem.menu = menu
}
constructMenu()
}