---
title: "setPrimaryConstituentDeviceSwitchingBehaviorForRecording(_:restrictedSwitchingBehaviorConditions:)"
framework: avfoundation
role: symbol
role_heading: Instance Method
path: "avfoundation/avcapturemoviefileoutput/setprimaryconstituentdeviceswitchingbehaviorforrecording(_:restrictedswitchingbehaviorconditions:)"
---

# setPrimaryConstituentDeviceSwitchingBehaviorForRecording(_:restrictedSwitchingBehaviorConditions:)

Sets the camera switching behavior to use during recording.

## Declaration

```swift
func setPrimaryConstituentDeviceSwitchingBehaviorForRecording(_ switchingBehavior: AVCaptureDevice.PrimaryConstituentDeviceSwitchingBehavior, restrictedSwitchingBehaviorConditions: AVCaptureDevice.PrimaryConstituentDeviceRestrictedSwitchingBehaviorConditions)
```

## Parameters

- `switchingBehavior`: The switching behavior to set on the movie file output. Attempting to restrict the switching behavior of a capture device that doesn’t support constituent device switching results in an error.
- `restrictedSwitchingBehaviorConditions`: The conditions during which camera switching occurs. Only set a condition when you set the switching behavior to doc://com.apple.avfoundation/documentation/AVFoundation/AVCaptureDevice/PrimaryConstituentDeviceSwitchingBehavior-swift.enum/restricted. In all other cases, set the value to doc://com.apple.avfoundation/documentation/AVFoundation/AVCapturePrimaryConstituentDeviceRestrictedSwitchingBehaviorConditions/AVCapturePrimaryConstituentDeviceRestrictedSwitchingBehaviorConditionNone.

## Discussion

Discussion Use this method to control the camera switching behavior the system uses when recording a movie. The behavior you specify takes effect when you enable it by setting the value of isPrimaryConstituentDeviceSwitchingBehaviorForRecordingEnabled to true. When a capture device doesn’t support constituent device selection, attempting to set a behavior other than AVCaptureDevice.PrimaryConstituentDeviceSwitchingBehavior.unsupported causes the system to throw an invalid argument exception.

## See Also

### Restricting camera switching

- [isPrimaryConstituentDeviceSwitchingBehaviorForRecordingEnabled](avfoundation/avcapturemoviefileoutput/isprimaryconstituentdeviceswitchingbehaviorforrecordingenabled.md)
- [primaryConstituentDeviceSwitchingBehaviorForRecording](avfoundation/avcapturemoviefileoutput/primaryconstituentdeviceswitchingbehaviorforrecording.md)
- [primaryConstituentDeviceRestrictedSwitchingBehaviorConditionsForRecording](avfoundation/avcapturemoviefileoutput/primaryconstituentdevicerestrictedswitchingbehaviorconditionsforrecording.md)
