Enable/Disable a Main Menu Item in Swift?

Hey Everyone, I am new to macOS development and am currently working on a project using storyboards where I would like a menu item in the main menu to be set to enabled when the user clicks on an row in a NSTableView.

Here is the code I am currently using in my ViewController:
Code Block
let mainMenu = NSApplication.shared.mainMenu!
func tableViewSelectionDidChange(_ notification: Notification) {
        if assetTableView.numberOfSelectedRows > 0 {
       
mainMenu.item(withTitle:"Edit")?.submenu?.item(withTag:0)!
.isEnabled = true
        }
    }

My project is setup to have a button called "Edit Asset" disabled on start until the user selects a row from an NSTableview to edit. Once they have a row selected I would like the main menu item "Edit Asset" to be enabled.

I used print statements to confirm that the code above does execute as well as has the correct menu item selected, yet it will still stay disabled during testing.

My only assumptions are that I am accessing a new or different instance of the main menu rather than the desired one, or I need to create a delegate protocol and tell the AppDelegate file to disable it for me. (Though these could be wrong approaches anyway)

I am quite stuck, so any suggestions or solutions would be greatly appreciated!

Answered by svandegrift in 624270022
I just figured it out (of course after writing that whole essay of a question). There is a checkbox in the Menu's Inspector called "Auto Enables Items" that was overriding my code. Once that check box is unchecked it worked immediately. Hope this helps anyone else who ever has this issue.
Accepted Answer
I just figured it out (of course after writing that whole essay of a question). There is a checkbox in the Menu's Inspector called "Auto Enables Items" that was overriding my code. Once that check box is unchecked it worked immediately. Hope this helps anyone else who ever has this issue.
Enable/Disable a Main Menu Item in Swift?
 
 
Q