ios - EXC_BAD_INSTRUCTION(代码=EXC_I386_INVOP,子代码=0x0)从 bundle 加载时出错

标签 ios swift exc-bad-instruction

我做一个计算只是为了好玩,我想在你按下按钮时添加声音。

错误是:

Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)

在这行代码上:

let alertSound = URL(fileURLWithPath: Bundle.main.path(forResource: "219069_annabloom_click1", ofType: "wav")!)

最佳答案

我认为问题出在这里

 let alertSound = URL(fileURLWithPath: Bundle.main.path(forResource: "219069_annabloom_click1", ofType: "wav")!)

这个符号的含义是!值不为零。 但我认为您没有正确添加文件,或者 .wav 扩展名存在问题,请仔细检查它,以便它返回 nil 并且应用程序崩溃。

Step 1: make sure you have added sound file correctly

Step 2: verify extension is same in code and file

确保选择该模块

enter image description here

关于ios - EXC_BAD_INSTRUCTION(代码=EXC_I386_INVOP,子代码=0x0)从 bundle 加载时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46680905/

相关文章:

ios 快速解析 : no results matched the query

swift - EXC_BAD_INSTRUCTION(代码 = EXC_I386_INVOP,子代码 = 0x0)

ios - UICollectioviewCell 中的 Uiview 的左下角和右下角半径问题

ios - 为什么我不能在 viewDidLoad 方法中的静态 UITableViewCell 中设置附件 View ?

ios - 需要UITableView的cellForRowAtIndexPath : to return nothing for some rows

iphone - 对象被过早释放?

swift - 整数值不更新

ios - Swift JavaScriptCore 有时会崩溃(bmalloc::VMHeap::grow())

multidimensional-array - EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP,subcode =0x0) 在 Swift 上处理多维数组时

ios - Swift append to array 在 32 位系统上给我 EXC_BAD_INSTRUCTION EXC_l386_INVOP