<!--
{
  "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/UserInfoKey",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:@T@NSUndoManagerUserInfoKey"
  },
  "title" : "UndoManager.UserInfoKey"
}
-->

# UndoManager.UserInfoKey

An extensible namespace for undo and redo user info keys.

```
struct UserInfoKey
```

## Discussion

Extend this type with the names of user info keys you want to associate with undo actions, like this:

```swift
extension UndoManager.UserInfoKey {
    static let icon: UndoManager.UserInfoKey = "icon"
}
```

You then use this key when you set and get undo user info values.

```swift
self.undoManager.setActionUserInfoValue(Image(named: "new_layer"), forKey: .icon)
```

## Topics

### Creating a user info key from a raw value

[`init(_:)`](/documentation/Foundation/UndoManager/UserInfoKey/init(_:))

Creates a user info key from the given string.

[`init(rawValue:)`](/documentation/Foundation/UndoManager/UserInfoKey/init(rawValue:))

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`RawRepresentable`](/documentation/Swift/RawRepresentable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Hashable`](/documentation/Swift/Hashable)

[`Equatable`](/documentation/Swift/Equatable)

---

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)