<!--
{
  "availability" : [
    "iOS: 3.0.0 -",
    "iPadOS: 3.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/UndoManager/prepare(withInvocationTarget:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSUndoManager(im)prepareWithInvocationTarget:"
  },
  "title" : "prepare(withInvocationTarget:)"
}
-->

# prepare(withInvocationTarget:)

Prepares the undo manager for invocation-based undo with the given target as the subject of the next undo operation.

```
func prepare(withInvocationTarget target: Any) -> Any
```

## Parameters

`target`

The target of the undo operation.

    The undo manager maintains a weak reference to     `target`    .

## Return Value

A proxy object that forwards messages to the undo manager for recording as undo actions.

## Discussion

---

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)