I am trying to change the audio output to the device when the user selects the option on an action sheet. This is the code that and when I select for the audio to go to the device, the bluetooth doesn't appear next time.:

```
for input in AVAudioSession.sharedInstance().availableInputs!{
            if input.portType == AVAudioSessionPortBluetoothA2DP || input.portType == AVAudioSessionPortBluetoothHFP || input.portType == AVAudioSessionPortBluetoothLE{
                let bluetooth = UIAlertAction(title: input.portName, style: .default, handler: {
                    (alert: UIAlertAction!) -> Void in
                    let audioSession = AVAudioSession.sharedInstance()
                    do {
                        try audioSession.setCategory(AVAudioSessionCategoryPlayAndRecord, with: AVAudioSessionCategoryOptions.allowBluetooth)
                        try audioSession.setActive(true)
                    } catch {
                        fatalError("Error Setting Up bluetooth output \(input.portName)")
                    }

                })

                bluetooth.setValue(UIImage(named:"bluetooth.png"), forKey: "image")
                optionMenu.addAction(bluetooth)
            }

let iphomeOutput = UIAlertAction(title: "iPhone", style: .default, handler: {
                (alert: UIAlertAction!) -> Void in
                let audioSession = AVAudioSession.sharedInstance()
                do {
                    do {
                        try audioSession.setCategory(AVAudioSessionCategoryPlayAndRecord, with: AVAudioSessionCategoryOptions.duckOthers)
                        try audioSession.setActive(true)
                    } catch {
                        fatalError("Error Setting Up audio output Phone")
                    }
                    try audioSession.overrideOutputAudioPort(AVAudioSessionPortOverride.none)
                } catch let error as NSError {
                    print("audioSession error turning off speaker: \(error.localizedDescription)")
                }
            })

            for description in currentRoute.outputs {
                if description.portType == AVAudioSessionPortHeadsetMic{
                    optionMenu.setValue(true, forKey: "checked")
                    break
                }
            }
            optionMenu.addAction(iphomeOutput)

```