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

# setCategory(_:)

Sets the audio session’s category.

## Declaration

```swift
func setCategory(_ category: AVAudioSession.Category) 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.

## Discussion

Discussion The audio session’s category defines how the app uses audio. Typically, you set the category before activating the session. You can also set the category while the session is active, but this results in an immediate route change. 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(_:options:)](avfaudio/avaudiosession/setcategory(_:options:).md)
- [setMode(_:)](avfaudio/avaudiosession/setmode(_:).md)
