<!--
{
  "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/UIMenuSystem",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIMenuSystem"
  },
  "title" : "UIMenuSystem"
}
-->

# UIMenuSystem

An object representing a main or contextual menu system.

```
@MainActor class UIMenuSystem
```

## Overview

A menu system groups root menus together. The [`main`](/documentation/UIKit/UIMenuSystem/main) system has only one root menu while the [`context`](/documentation/UIKit/UIMenuSystem/context) system can have multiple root menus, each built in different [`UIResponder`](/documentation/UIKit/UIResponder) objects like a view controller.

Use [`UIMenuSystem`](/documentation/UIKit/UIMenuSystem) in your implementation of [`buildMenu(with:)`](/documentation/UIKit/UIResponder/buildMenu(with:)) to isolate changes to a specific system.

```swift
override func buildMenu(with builder: UIMenuBuilder) {
    super.buildMenu(with: builder)
    
    // Ensure that the builder is modifying the menu bar system.
    guard builder.system == UIMenuSystem.main else { return }

    // ...
}
```

You can also use a menu system to rebuild or revalidate menus as changes occur in your app. To rebuild a menu, call the [`setNeedsRebuild()`](/documentation/UIKit/UIMenuSystem/setNeedsRebuild()) method. Call [`setNeedsRevalidate()`](/documentation/UIKit/UIMenuSystem/setNeedsRevalidate()) when you need the menu system to revalidate a menu.

For more information, see [Adding menus and shortcuts to the menu bar and user interface](/documentation/UIKit/adding-menus-and-shortcuts-to-the-menu-bar-and-user-interface).

## Topics

### Getting a menu system

[`main`](/documentation/UIKit/UIMenuSystem/main)

The main menu system.

[`context`](/documentation/UIKit/UIMenuSystem/context)

The context menu system.

### Rebuilding a menu system

[`setNeedsRebuild()`](/documentation/UIKit/UIMenuSystem/setNeedsRebuild())

Tells the menu system to rebuild all of its menus.

### Revalidating a menu system

[`setNeedsRevalidate()`](/documentation/UIKit/UIMenuSystem/setNeedsRevalidate())

Tells the menu system to validate all of its menus.

### Setting group preferences

[`UIMenuSystem.ElementGroupPreference`](/documentation/UIKit/UIMenuSystem/ElementGroupPreference)



---

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)