<!--
{
  "availability" : [
    "macCatalyst: 13.1.0 - 13.1.0",
    "macOS: 10.0.0 - 10.13.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSDistantObject/proxyWithTarget:connection:",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSDistantObject(cm)proxyWithTarget:connection:"
  },
  "title" : "proxyWithTarget:connection:"
}
-->

# proxyWithTarget:connection:

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

```
+ (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` [`connectionWithRegisteredName:host:`](/documentation/Foundation/NSConnection/connectionWithRegisteredName:host:) class method.

## Return Value

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

## Discussion

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

---

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)