Reputation: 3
func randomroll () {
var time = arc4random_uniform(10)
while(time < 5)
{
time = arc4random_uniform(10)
}
for(var time1 = time; time1>=0; time1--) { //This is where I get the thread error
...
}
}
The error I am getting is Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
I am a beginner swift programmer and am sure I am missing something obvious, was hoping for some insight. Thank you.
Upvotes: 0
Views: 212
Reputation: 8883
func randomroll() {
var time = Int(arc4random_uniform(10))
while(time < 5)
{
time = Int(arc4random_uniform(10))
}
for time; time >= 0; time-- { //This is where I get thread error
println(time)
}
}
randomroll()
time
is an Uint32 and can't be negative. So either don't let it become negative or convert it to an Int
Upvotes: 1