这是我在Swift 2中的代码。
我如何在Swift 3中使用相同的东西?
NotificationCenter.default.addObserver(self, selector: "handleInterruption", name: AVAudiosessionInterruptionNotification, object: nil)
提前感谢您!
因此,在您的情况下,您可能正在寻找所有系统通知类型现在都被定义为Notification.Name上的静态常量;即.UIApplicationDidFinishLaunching,.UITextFieldTextDidChange等。
Notification.Name.AVAudioSessionInterruption
我认为这对您应该有用:NotificationCenter.default.addObserver(self, selector: #selector(handleInterruption), name: .AVAudioSessionInterruption, object: nil)