<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UICommand",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UICommand"
  },
  "title" : "UICommand"
}
-->

# UICommand

A menu element that performs its action in a selector.

```
@MainActor class UICommand
```

## Overview

Create a [`UICommand`](/documentation/UIKit/UICommand) object when you want a menu element that performs its action in a selector available in the responder chain.

```swift
// 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:)`](/documentation/UIKit/UICommand/init(title:subtitle:image:action:propertyList:alternates:discoverabilityTitle:attributes:state:))

Creates a command with the specified title, subtitle, image, action, property list, alternative commands, discoverability title, attributes, and state.

[`init(title:image:action:propertyList:alternates:discoverabilityTitle:attributes:state:)`](/documentation/UIKit/UICommand/init(title:image:action:propertyList:alternates:discoverabilityTitle:attributes:state:))

Creates a command with the specified title, image, action, property list, alternative commands, discoverability title, attributes, and state.

[`commandWithTitle:image:action:propertyList:`](/documentation/UIKit/UICommand/commandWithTitle:image:action:propertyList:)

Creates a command with the specified title, image, action, and property list.

[`commandWithTitle:image:action:propertyList:alternates:`](/documentation/UIKit/UICommand/commandWithTitle:image:action:propertyList:alternates:)

Creates a command with the specified title, image, action, property list, and alternative commands.

[`init(coder:)`](/documentation/UIKit/UICommand/init(coder:))

Creates a command from data in an unarchiver.

[Adding menus and shortcuts to the menu bar and user interface](/documentation/UIKit/adding-menus-and-shortcuts-to-the-menu-bar-and-user-interface)

Provide quick access to useful actions by adding menus and keyboard shortcuts to your Mac app built with Mac Catalyst.

### Getting information about the command

[`title`](/documentation/UIKit/UICommand/title)

The command’s title.

[`image`](/documentation/UIKit/UICommand/image)

The command’s image.

[`action`](/documentation/UIKit/UICommand/action)

The selector identifying the action method called after the user selects the command.

[`discoverabilityTitle`](/documentation/UIKit/UICommand/discoverabilityTitle)

An elaborated title that explains the purpose of the command.

[`attributes`](/documentation/UIKit/UICommand/attributes)

The attributes indicating the style of the command.

[`state`](/documentation/UIKit/UICommand/state)

The state of the command.

### Getting command alternatives

[`alternates`](/documentation/UIKit/UICommand/alternates)

An array of alternative actions to take for the command.

[`UICommandAlternate`](/documentation/UIKit/UICommandAlternate)

An object representing an alternative action for a command.

### Associating data

[`propertyList`](/documentation/UIKit/UICommand/propertyList)

An object that contains data to associate with the command.

[`UICommandTagShare`](/documentation/UIKit/UICommandTagShare)

A value that identifies a command as a Share menu.

### Initializers

[`init(title:subtitle:image:selectedImage:action:propertyList:alternates:discoverabilityTitle:attributes:state:)`](/documentation/UIKit/UICommand/init(title:subtitle:image:selectedImage:action:propertyList:alternates:discoverabilityTitle:attributes:state:))



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)