Swift Random Number崩溃App

时间:2014-09-09 13:32:13

标签: random swift

我尝试在Swift中生成一个随机数并用它做不同的语句,这是我的代码

override func motionEnded(motion: UIEventSubtype, withEvent event: UIEvent!) {

    if event.subtype == UIEventSubtype.MotionShake{

        var randomNumber: Int = Int(arc4random()) % 1
        println(randomNumber)

        if randomNumber == 1{
            println("ist1")
        }else{
            println("nicht")
        }

    }
}

如果randomNumber == 1变为true,则应用程序崩溃

  

“线程1:EXC_BAD_INSTRUCION(code_I386_INVOP,子码= 0x0)

知道我做错了吗?

enter image description here

http://i.stack.imgur.com/lC79Z.png

0 个答案:

没有答案