Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @IBAction func switchSelection(_ sender: UIButton) {
- if startStopButton.currentTitle! == "Start" {
- startStopButton.setTitle("Stop", for: UIControlState())
- do {
- switch theAlertType {
- case 1:
- self.audioPlayer = try AVAudioPlayer(contentsOf: alert1)
- default:
- self.audioPlayer = try AVAudioPlayer(contentsOf: alert2)
- }
- pickerView.isUserInteractionEnabled = false
- alertTypeSegmentedControl.isEnabled = false
- self.playAlert()
- self.theTimer.invalidate()
- self.theTimer = Timer.scheduledTimer(timeInterval: theInterval,
- target: self, selector: #selector(ViewController.playAlert),
- userInfo: nil, repeats: true)
- } catch {
- print("Error getting the audio file")
- }
- } else {
- startStopButton.setTitle("Start", for: UIControlState())
- pickerView.isUserInteractionEnabled = true
- alertTypeSegmentedControl.isEnabled = true
- self.audioPlayer.stop()
- self.theTimer.invalidate()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement