我正在研究這個記錄器項目,這個代碼是用swift 2.0編寫的,它給出了這個問題! 我似乎類似的標題文章,但不涉及我有線程1:exc_bad_instruction(代碼= exc_i386_invop子代碼= 0x0)錯誤
進口的UIKit 進口AVFoundation
類PlaySoundViewController問題:的UIViewController {
var audioPlayer: AVAudioPlayer!
var receivedAudio: AudioRecorded!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
do{
let audioPlayer = try AVAudioPlayer(contentsOfURL: receivedAudio.filePathUrl) --> ***The error happens here***
audioPlayer.enableRate = true
}catch let ErrorType {
NSLog("Could not create AVAudioPlayer: \(ErrorType)")
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func playFastSound(sender: AnyObject) {
audioPlayer.stop()
audioPlayer.play()
audioPlayer.rate = 2.0
}
@IBAction func playSlowSound(sender: AnyObject)
{
audioPlayer.stop()
audioPlayer.play()
audioPlayer.rate = 0.5
}
@IBAction func stopPlaying(sender: AnyObject) {
audioPlayer.stop()
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
你能發佈爲「receivedAudio.filePathUrl」返回的網址嗎? –