<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 10.7.0 -",
    "tvOS: 17.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVCaptureVideoPreviewLayer/connection",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVCaptureVideoPreviewLayer(py)connection"
  },
  "title" : "connection"
}
-->

# connection

An object that describes the connection from the layer to a particular input port.

```
var connection: AVCaptureConnection? { get }
```

## Discussion

When you associate a preview layer with a capture session, the session automatically creates a connection to the first eligible video [`AVCaptureInput.Port`](/documentation/AVFoundation/AVCaptureInput/Port) object. If you detach a preview layer from a session, the connection property becomes `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)