---
title: "setCategory(_:options:)"
framework: avfaudio
role: symbol
role_heading: Instance Method
path: "avfaudio/avaudiosession/setcategory(_:options:)"
---

# setCategory(_:options:)

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

## Declaration

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

## Parameters

- `category`: The category to apply to the audio session. See doc://com.apple.avfaudio/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 doc://com.apple.avfaudio/documentation/AVFAudio/AVAudioSession/CategoryOptions-swift.struct.

## Discussion

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 for category compatibility. note: Instead of setting your category and mode properties independently, set them at the same time using the setCategory(_:mode:options:) or setCategory(_:mode:policy:options:) method.

## See Also

### Configuring standard audio behaviors

- [setCategory(_:mode:policy:options:)](avfaudio/avaudiosession/setcategory(_:mode:policy:options:).md)
- [setCategory(_:mode:options:)](avfaudio/avaudiosession/setcategory(_:mode:options:).md)
- [setCategory(_:)](avfaudio/avaudiosession/setcategory(_:).md)
- [setMode(_:)](avfaudio/avaudiosession/setmode(_:).md)
