---
title: "prepare(withInvocationTarget:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/undomanager/prepare(withinvocationtarget:)"
---

# prepare(withInvocationTarget:)

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

## Declaration

```swift
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

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

## See Also

### Registering undo operations

- [registerUndo(withTarget:handler:)](foundation/undomanager/registerundo(withtarget:handler:).md)
- [registerUndo(withTarget:selector:object:)](foundation/undomanager/registerundo(withtarget:selector:object:).md)
