EXC_BAD_ACCESS主题1。代码如下。 swift 3
问题描述:
我在这个问题上从一个星期开始工作,试图用新的代码替换大多数代码,并且它仍然崩溃,下面有错误。 Google搜索了一周,研究了几乎所有主题。最后来到这里寻求帮助。EXC_BAD_ACCESS主题1。代码如下。 swift 3
0x10006dc50 < +84>:bl 0x100072fcc;符号存根 for:objc_msgSend 0x10006dc54 < +88>:ldr x0,[sp,#8] 0x10006dc58 < +92>:bl 0x100072fe4;符号存根:objc_release 0x10006dc5c < 96>:ADRP X8,11
EXC_BAD_ACCESS线程1。下面的代码为 。
//--------------calmingseaplayer-----------------
do {
let audioPath = Bundle.main.path(forResource: "calming", ofType: "wav")
try morningdewplayer = AVAudioPlayer(contentsOf:URL(fileURLWithPath: audioPath!))
}
catch { //Error }
答
部队去包裹可能不是你想要在这里做,验证与audioPath
的网址是不是守着它无什么。
guard let audioPath = Bundle.main.path(forResource: "calming", ofType: "wav") else { print("Incorrect audio path"); return }
guard let url = URL(fileURLWithPath: audioPath) else { print("URL is nil"); return }
try morningdewplayer = AVAudioPlayer(contentsOf:url)
将代码发布到崩溃位置。坏访问意味着一个对象被释放,你试图使用它(或发送邮件到它) – ohr
进口的UIKit 进口AVFoundation 级的音乐:UIViewController的{ VAR morningdewplayer = AVAudioPlayer() VAR birdplayer = AVAudioPlayer() VAR平静= AVAudioPlayer() VAR笛= AVAudioPlayer() 覆盖FUNC viewDidLoad中() 做{ 让audioPath = Bundle.main.path(forResource: “早晨”,ofType: “MP3”) 尝试morningdewplayer = AVAudioPlayer (contentsOf:URL(fileURLWithPath:audioPath!)) } catch { // Error } – Neeld
用您的代码编辑您的原始文章,而不是在评论中:) – ohr