steph
steph

Reputation: 43

How to set several options in the setCategory method of AVAudioSession in Objective-C?

I am trying to use AVAudioSession setCategory method with several options and I have seen online that you can specify an array to the options argument in swift but cannot figure out how to do it in objective-C. Here is the documentation where you can see the difference of the options argument expected in swift vs objective-C:

I have tried with objective-C arrays and it does store the options expected.

Thanks for your help!

Upvotes: 4

Views: 2678

Answers (1)

Asperi
Asperi

Reputation: 257693

Category options is bit mask. Here is an example of usage

    AVAudioSession *session = AVAudioSession.sharedInstance;
    NSError *error = nil;
    [session setCategory:AVAudioSessionCategoryPlayAndRecord
                    mode:AVAudioSessionModeVoiceChat
                 options:AVAudioSessionCategoryOptionDefaultToSpeaker|AVAudioSessionCategoryOptionDuckOthers
                   error:&error];
    if (nil == error)
    {
        // continue here
    }

Upvotes: 8

Related Questions