---
title: "proxyWithTarget:connection:"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/nsdistantobject/proxywithtarget:connection:"
---

# proxyWithTarget:connection:

Returns a remote proxy for a given object and connection, creating the proxy if necessary.

## Declaration

```occ
+ (id) proxyWithTarget:(id) target connection:(NSConnection *) connection;
```

## Parameters

- `target`: An object in another thread or another application’s address space.
- `connection`: The connection to set as the NSConnection object for the returned proxy—it should have been created using the NSConnection doc://com.apple.foundation/documentation/Foundation/NSConnection/connectionWithRegisteredName:host: class method.

## Return Value

Return Value A remote proxy for target and connection, creating the proxy if necessary

## Discussion

Discussion A remote proxy cannot be used until its connection’s peer has a local proxy representing target in the other application.

## See Also

### Creating a Remote Proxy

- [initWithTarget:connection:](foundation/nsdistantobject/initwithtarget:connection:.md)
