<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.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/setCategory(_:options:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFAudio"
    ],
    "preciseIdentifier" : "c:objc(cs)AVAudioSession(im)setCategory:withOptions:error:"
  },
  "title" : "setCategory(_:options:)"
}
-->

# setCategory(_:options:)

Sets the audio session’s category with the specified options.

```
func setCategory(_ category: AVAudioSession.Category, options: AVAudioSession.CategoryOptions = []) throws
```

## Parameters

`category`

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

`options`

A mask of additional options for handling audio. For a list of constants, see [`AVAudioSession.CategoryOptions`](/documentation/AVFAudio/AVAudioSession/CategoryOptions-swift.struct).

## Discussion

The audio session’s category defines how you intend to use audio in your app. Typically, you set the category before activating the session. You can also set the category while the session is active, but doing so results in an immediate route change.

You can tailor the behavior of certain categories by specifying a mask of category options. Specifying an unsupported option for the indicated category results in an error. See [`AVAudioSession.CategoryOptions`](/documentation/AVFAudio/AVAudioSession/CategoryOptions-swift.struct) for category compatibility.

> 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)