我对Swift和Objective C完全陌生。在这里,我试图从以下语句调用函数。但是,Xcode将其显示为无效语法。您能帮忙指出此语法有什么问题吗?
NotificationCenter.default.addObserver(self, selector: handleInterruption(notification: NSNotification), name: NSNotification.Name.AVAudioSessionInterruption, object: nil)
func handleInterruption(notification: NSNotification) {
player.pauseAudio()
let interruptionTypeAsObject = notification.userInfo![AVAudioSessionInterruptionTypeKey] as! NSNumber
let interruptionType = AVAudioSessionInterruptionType(rawValue: interruptionTypeAsObject.uintValue)
if let type = interruptionType {
if type == .ended {
player.playAudio()
}
}
}