致命错误:在隐式展开一个可选值时意外发现nil。火箭发射

时间:2019-10-26 17:49:58

标签: ios swift

每次我尝试运行我的应用程序时,都会显示以下错误: 意外发现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
    }
}

0 个答案:

没有答案