<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSFileProviderService/getFileProviderConnection(completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSFileProviderService(im)getFileProviderConnectionWithCompletionHandler:"
  },
  "title" : "getFileProviderConnection(completionHandler:)"
}
-->

# getFileProviderConnection(completionHandler:)

Asynchronously returns the service’s connection object.

```
func getFileProviderConnection(completionHandler: @escaping @Sendable (NSXPCConnection?, (any Error)?) -> Void)
```

## Parameters

`completionHandler`

A block that is called on an anonymous background queue. The system passes this block the following parameters:

- `connection`: An [`NSXPCConnection`](/documentation/Foundation/NSXPCConnection) object for the service, or `nil` if an error occurs.
- `error`: If an error occurs, this property contains an object that describes the error; otherwise, it is set to `nil`.

---

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)