本文介绍了使用多维数组时,Swift 上的 EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP,subcode =0x0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试创建一个包含带枚举的数组的数组时出现此错误.

I get this error when I try to create an array which contain arrays with enums.

为了更好地说明这里的代码:

To illustrate better here's the code:

let block1:Form[] = [Form.Circle, Form.Rectangle, Form.Triangle]
let block2:Form[] = [Form.Rectangle, Form.Circle, Form.Triangle]
let block3:Form[] = [Form.Rectangle, Form.Triangle, Form.Circle]
let block4:Form[] = [Form.Circle, Form.Triangle, Form.Rectangle]
let block5:Form[] = [Form.Triangle, Form.Circle, Form.Rectangle]
let block6:Form[] = [Form.Triangle, Form.Rectangle, Form.Circle]
var allBlocks:(Form[][])!

这些是保存枚举的数组,最后一个将保存这些数组.

These are the arrays holding the enums and the last one will hold these arrays.

override func didMoveToView(view: SKView) {

          allBlocks = [block1, block2, block3, block4, block5, block6] //Error here
...
}

当我尝试将值分配给 allBlocks 时发生错误

The error occurs when I try to assign the value to allBlocks

如果我把代码改成这样,我就不会出错:

If I change the code to this I get no error:

let block1:Form[] = [Form.Circle, Form.Rectangle, Form.Triangle]
let block2:Form[] = [Form.Rectangle, Form.Circle, Form.Triangle]
let block3:Form[] = [Form.Rectangle, Form.Triangle, Form.Circle]
let block4:Form[] = [Form.Circle, Form.Triangle, Form.Rectangle]
let block5:Form[] = [Form.Triangle, Form.Circle, Form.Rectangle]
let block6:Form[] = [Form.Triangle, Form.Rectangle, Form.Circle]

override func didMoveToView(view: SKView) {

         var allBlocks = [block1, block2, block3, block4, block5, block6] //No error
...
}

但是我无法在其他地方访问 allBlocks 变量.

But then I can't access the allBlocks variable in another place.

如果有帮助

推荐答案

这听起来像是 Swift 编译器的错误;崩溃是由于试图执行非法的 x86 指令,因此编译器生成了无效代码,或者生成了一个指向根本不是代码或不是指令开头的分支.

This sounds like a Swift compiler bug; the crash was due to an attempt to execute an illegal x86 instruction, so either the compiler generated invalid code or generated a branch to something that wasn't code at all or wasn't the beginning of an instruction.

想必您正在对 Xcode 进行 beta 测试,因此,如果您还没有可以在 Radar 上提交错误的 Apple Developer Connection 帐户^WApple Bug Reporter,打开一个帐户,然后提交一个 Bug.(作为 Xcode 下载的一部分,Apple 可能已经提供了这方面的详细信息.)

Presumably you're beta-testing Xcode, so, if you don't already have an Apple Developer Connection account that lets you file bugs on Radar^WApple Bug Reporter, open an account, and then file a bug. (Apple may have given details on this as part of the Xcode download.)

这篇关于使用多维数组时,Swift 上的 EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP,subcode =0x0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-19 01:27