UICommand
A menu element that performs its action in a selector.
Declaration
@MainActor class UICommandOverview
Create a UICommand object when you want a menu element that performs its action in a selector available in the responder chain.
// Create a selector-based action to use as a menu element.
let refreshCommand = UICommand(title: "Refresh", action: #selector(refreshData(_:)))
// Use the .displayInline option to avoid displaying the menu as a submenu,
// and to separate it from the other menu elements using a line separator.
let refreshMenuItem = UIMenu(title: "", options: .displayInline, children: [refreshCommand])
// Insert the menu into the File menu before the Close menu.
builder.insertSibling(refreshMenuItem, beforeMenu: .close)Topics
Creating a command
init(title:subtitle:image:action:propertyList:alternates:discoverabilityTitle:attributes:state:)init(title:image:action:propertyList:alternates:discoverabilityTitle:attributes:state:)init(coder:)Adding menus and shortcuts to the menu bar and user interface