I use this method:
public func setCategory(category: String, withOptions options: AVAudioSessionCategoryOptions) throws
It's an AVAudioSession method and as you can see it doesnt return anything but it should throw and error.
I do like this:
try? AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, withOptions: .MixWithOthers)
This gives me an annoying warning:
Result of 'try?' is unused
I tried to set it into a variable and put it into a do-catch but still the same warning...
How can I get rid of this warning?
Just replace ?
with !
and it will look like:
try! AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, withOptions: .MixWithOthers)
And your warning will gone.
UPDATE:
This won't crash:
_ = try? AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, withOptions: .MixWithOthers)