每次我尝试运行我的应用程序时,都会显示以下错误: 意外发现nil,同时隐式展开一个可选值
能帮我吗?
let path = Bundle.main.path(forResource: "rocketsound", ofType: "wav")!
let url = URL(fileURLWithPath: path)
do {
player = try AVAudioPlayer(contentsOf: url)
player.prepareToPlay()
} catch let error as NSError {
print(error.description)
}
}
@IBAction func buttonisPressed(_ sender: Any) {
player.play()
UIView.animate(withDuration: 2.3, animations: {
self.rocket.frame = CGRect(x: 0, y: 140, width: 375, height: 402)
}) { (finished) in
self.textLbl.ishidden = true
self.buttonLbl.ishidden = true
}
}