使用 Swift,我似乎只在使用 arc4random 时偶尔会收到此错误.为什么,我该如何解决? [英] Using Swift, I seem to get this error ONLY SOMETIMES when using arc4random. Why, and how do I fix it?

查看:21
本文介绍了使用 Swift,我似乎只在使用 arc4random 时偶尔会收到此错误.为什么,我该如何解决?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此错误:

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

大部分时间(不是全部)当我在 Xcode 6 和 Swift 中使用 arc4random() 时.我从来没有在 Objective C 的 Xcode 5 中遇到过这个错误.奇怪的是,如果我使用 arc4random_uniform(),我不会遇到这个问题.

Most of the time (not all) when I'm using arc4random() in Xcode 6 with Swift. I didn't ever get this error in Xcode 5 in Objective C. Curiously, if I use arc4random_uniform(), I don't run into this problem.

如何使用 arc4random() 而不会出现此错误?

How do I use arc4random() without getting this error?

推荐答案

你必须使用它:

var _shiom = Int(arc4random_uniform(UInt32(arrayshiftingTile.count)))

这篇关于使用 Swift,我似乎只在使用 arc4random 时偶尔会收到此错误.为什么,我该如何解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆