[ad_1]
that is the code and it is giving me an Error.
let espresso = sender.currentTitle!
thats my drawback Im attempting to make my button be the title of the button which is Decaf however when i press it it provides me that Error.
import UIKit
import AVFoundation
class ViewController: UIViewController {
override func viewDidLoad() {
tremendous.viewDidLoad()
// Do any extra setup after loading the view.
}
@IBOutlet weak var progressBar: UIProgressView!
@IBOutlet weak var titleLabel: UILabel!
let coffeeTimes = ["Decaf": 5, "coffee": 5]
var timer = Timer()
var participant: AVAudioPlayer!
var totalTime = 0
var secondsPassed = 0
@IBAction func coffeeSelected(_ sender: UIButton) {
timer.invalidate()
let espresso = sender.currentTitle! 1.That is the road have been its giving me the Error"
totalTime = coffeeTimes[coffee]!
progressBar.progress = 0.0
secondsPassed = 0
titleLabel.textual content = espresso
timer = Timer.scheduledTimer(timeInterval: 1.0, goal:self, selector: #selector(updateTimer), userInfo:nil, repeats: true)
}
@objc func updateTimer() {
if secondsPassed < totalTime {
secondsPassed += 1
progressBar.progress = Float(secondsPassed) / Float(totalTime)
print(Float(secondsPassed) / Float(totalTime))
} else {
timer.invalidate()
titleLabel.textual content = "examine espresso"
let url = Bundle.predominant.url(forResource: "alarm_sound", withExtension: "mp3")
participant = attempt! AVAudioPlayer(contentsOf: url!)
participant.play()
}
}
}
[ad_2]
