---
title: "forwardInvocation(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsproxy/forwardinvocation(_:)"
---

# forwardInvocation(_:)

Passes a given invocation to the real object the proxy represents.

## Declaration

```swift
func forwardInvocation(_ invocation: NSInvocation)
```

## Parameters

- `invocation`: The invocation to forward.

## Discussion

Discussion NSProxy’s implementation merely raises NSInvalidArgumentException. Override this method in your subclass to handle invocation appropriately, at the very least by setting its return value. For example, if your proxy merely forwards messages to an instance variable named realObject, it can implement forwardInvocation(_:) like this: - (void)forwardInvocation:(NSInvocation *)anInvocation {     [anInvocation setTarget:realObject];     [anInvocation invoke];     return; }
