<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFAudio",
  "identifier" : "/documentation/AVFAudio/AVAudioSession/setMode(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFAudio"
    ],
    "preciseIdentifier" : "c:objc(cs)AVAudioSession(im)setMode:error:"
  },
  "title" : "setMode(_:)"
}
-->

# setMode(_:)

Sets the audio session’s mode.

```
func setMode(_ mode: AVAudioSession.Mode) throws
```

## Parameters

`mode`

The audio session mode to apply to the audio session. See [`AVAudioSession.Mode`](/documentation/AVFAudio/AVAudioSession/Mode-swift.struct) for supported mode values.

## Discussion

The audio session’s category and mode together define how your app uses audio. Typically, you set the category and mode before activating the session. You can also set the category or mode while the session is active, but doing so results in an immediate change.

> Note:
> Instead of setting your ``doc://com.apple.avfaudio/documentation/AVFAudio/AVAudioSession/category-swift.property`` and ``doc://com.apple.avfaudio/documentation/AVFAudio/AVAudioSession/mode-swift.property`` properties independently, set them at the same time using the ``doc://com.apple.avfaudio/documentation/AVFAudio/AVAudioSession/setCategory(_:mode:options:)`` or ``doc://com.apple.avfaudio/documentation/AVFAudio/AVAudioSession/setCategory(_:mode:policy:options:)`` method.

---

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)