4

This is the code I had in swift 2.

How do I use the same thing in swift 3?

NotificationCenter.default.addObserver(self, selector: "handleInterruption", name: AVAudiosessionInterruptionNotification, object: nil)

Thanks in advance!

EI Captain v2.0
  • 21,360
  • 10
  • 76
  • 103

1 Answers1

5

Have a look at this fine answer

As it says:

All of the system notification types are now defined as static constants on Notification.Name; i.e. .UIApplicationDidFinishLaunching, .UITextFieldTextDidChange, etc.

So, in your case, you are probably looking for Notification.Name.AVAudioSessionInterruption

And I think this should work for you:

NotificationCenter.default.addObserver(self, selector: #selector(handleInterruption), name: .AVAudioSessionInterruption, object: nil)

Hope that helps.

Community
  • 1
  • 1
pbodsk
  • 6,371
  • 3
  • 20
  • 47