0

这在 StackOverflow 的其他地方提到过,但我找不到与这里发生的事情相关的最近示例。我转换为 Swift 5,现在出现了这个错误。围绕实际错误消息有很多想法,但没有任何线索可以让我知道这一点。我在这里想念什么?

这行代码中的“表达式类型不明确,没有更多上下文”;

try? audioSession.setCategory(convertFromAVAudioSessionCategory(AVAudioSession.Category.playback), with: [.defaultToSpeaker, .allowBluetooth])

在 FRadioPlayer.swift: 文件中的代码中,该文件位于 GitHub 的 fethica/FRRadioPlayer 中。

    // MARK: - Initialization

private override init() {
    super.init()

    // Enable bluetooth playback
    let audioSession = AVAudioSession.sharedInstance()
    try? audioSession.setCategory(convertFromAVAudioSessionCategory(AVAudioSession.Category.playback), with: [.defaultToSpeaker, .allowBluetooth])
    // Notifications
    setupNotifications()

    // Check for headphones
    checkHeadphonesConnection(outputs: AVAudioSession.sharedInstance().currentRoute.outputs)

    // Reachability config
    try? reachability.startNotifier()
    NotificationCenter.default.addObserver(self, selector: #selector(reachabilityChanged(note:)), name: .reachabilityChanged, object: reachability)
    isConnected = reachability.connection != .none
}
4

0 回答 0