<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 2.1.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVCaptureDevice/default(_:for:position:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVCaptureDevice(cm)defaultDeviceWithDeviceType:mediaType:position:"
  },
  "title" : "default(_:for:position:)"
}
-->

# default(_:for:position:)

Returns the default device for the specified device type, media type, and position.

```
class func `default`(_ deviceType: AVCaptureDevice.DeviceType, for mediaType: AVMediaType?, position: AVCaptureDevice.Position) -> AVCaptureDevice?
```

## Parameters

`deviceType`

The type of capture device to request, such as [`builtInWideAngleCamera`](/documentation/AVFoundation/AVCaptureDevice/DeviceType-swift.struct/builtInWideAngleCamera).

`mediaType`

The type of media to request capture of, such as [`video`](/documentation/AVFoundation/AVMediaType/video) or [`audio`](/documentation/AVFoundation/AVMediaType/audio).

`position`

The position of capture device to request relative to system hardware (front- or back-facing). Pass [`AVCaptureDevice.Position.unspecified`](/documentation/AVFoundation/AVCaptureDevice/Position-swift.enum/unspecified) to search for devices regardless of position.

## Return Value

The default system device, or `nil` if no device currently exists that satisfies the specified criteria.

## Discussion

Use this method to select the system default capture device for a given scenario. For example, to obtain the dual camera on supported hardware and fall back to the standard wide-angle camera otherwise, call this method twice, as shown below.

```swift
// The app's default camera.
var defaultCamera: AVCaptureDevice? {
    // Find the built-in dual camera, if it exists.
    if let device = AVCaptureDevice.default(.builtInDualCamera,
                                            for: .video,
                                            position: .back) {
        return device
    }
    
    // Find the built-in wide-angle camera, if it exists.
    if let device = AVCaptureDevice.default(.builtInWideAngleCamera,
                                            for: .video,
                                            position: .back) {
        return device
    }
    return 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)