Instance Method


Sets the audio session category, mode, and desired options.


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



The category to apply to the audio session. See Audio Session Categories for supported category values.


The audio session mode to apply to the audio session. For a list of values, see Audio Session Modes.


A mask of additional options for handling audio. For a list of constants, see AVAudioSession.CategoryOptions.

Return Value

Returns true if the audio session category and options were set successfully, or false otherwise.


The audio session's category and mode together define how your app intends to use 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 this results in an immediate change.

See Also

Configuring the Audio Session

var category: AVAudioSession.Category

The current audio session category.

func setCategory(AVAudioSession.Category)

Sets the current audio session category.

func setCategory(AVAudioSession.Category, options: AVAudioSession.CategoryOptions)

Sets the audio session category with the specified options.

var availableCategories: [AVAudioSession.Category]

The audio session categories available on the current device.

var categoryOptions: AVAudioSession.CategoryOptions

The mask of options associated with the current audio session category.

var mode: AVAudioSession.Mode

The current audio session mode.

func setMode(AVAudioSession.Mode)

Sets the audio session mode.

var availableModes: [AVAudioSession.Mode]

The audio session modes available on the device.