Solution for Ch 21 Challenge: Menu Item

The solution is based on the existing remove employee button that works perfectly.

In Document.swift, add the code below:

@IBOutlet weak var removeEmployeeButton: NSButton!

@IBAction func removeEmployeeMenuItemClicked(_ sender: NSMenuItem) {
  removeEmployees(removeEmployeeButton)
}

override func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
  guard let action = menuItem.action else {
    return super.validateMenuItem(menuItem)
  }
  
  switch action {
  case #selector(removeEmployeeMenuItemClicked(_:)):
    return removeEmployeeButton.isEnabled
  default:
    return true
  }
}