---
title: "undoActionUserInfoValue(forKey:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/undomanager/undoactionuserinfovalue(forkey:)"
---

# undoActionUserInfoValue(forKey:)

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

## Declaration

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

## Parameters

- `key`: The key associated with the value to return.

## Return Value

Return Value The value that you previously registered to this key with setActionUserInfoValue(_:forKey:), or nil if the key is absent.

## Discussion

Discussion Use this method to retrieve a user info value for the undo action you previously set with setActionUserInfoValue(_:forKey:). In this example, an app’s undoButton() method provides a SwiftUI view that incorporates a previously assigned icon for the undo action: func undoButton() -> some SwiftUI.View {     Button(action: {         self.undoManager.undo()     }) {         Label(self.undoManager.undoActionName,               image: self.undoManager.undoActionUserInfoValue(forKey: .icon) as? Image)     } }

## See Also

### Working with user info

- [setActionUserInfoValue(_:forKey:)](foundation/undomanager/setactionuserinfovalue(_:forkey:).md)
- [redoActionUserInfoValue(forKey:)](foundation/undomanager/redoactionuserinfovalue(forkey:).md)
- [UndoManager.UserInfoKey](foundation/undomanager/userinfokey.md)
