<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/UndoManager/undoActionUserInfoValue(forKey:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSUndoManager(im)undoActionUserInfoValueForKey:"
  },
  "title" : "undoActionUserInfoValue(forKey:)"
}
-->

# undoActionUserInfoValue(forKey:)

Retrieves the undo action’s user info value for the given key.

```
func undoActionUserInfoValue(forKey key: UndoManager.UserInfoKey) -> Any?
```

## Parameters

`key`

The key associated with the value to return.

## Return Value

The value that you previously registered to this key with [`setActionUserInfoValue(_:forKey:)`](/documentation/Foundation/UndoManager/setActionUserInfoValue(_:forKey:)), or `nil` if the key is absent.

## Discussion

Use this method to retrieve a user info value for the undo action you previously set with [`setActionUserInfoValue(_:forKey:)`](/documentation/Foundation/UndoManager/setActionUserInfoValue(_:forKey:)).

In this example, an app’s `undoButton()` method provides a SwiftUI view that incorporates a previously assigned icon for the undo action:

```swift
func undoButton() -> some SwiftUI.View {
    Button(action: {
        self.undoManager.undo()
    }) {
        Label(self.undoManager.undoActionName,
              image: self.undoManager.undoActionUserInfoValue(forKey: .icon) as? Image)
    }
}
```

---

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)