Function arc4random
returns an UInt32
. If you get a value higher than Int.max
, the Int(...)
cast will crash.
Using
Int(arc4random_uniform(UInt32(items.count)))
should be a better solution.
(Blame the strange crash messages in the Alpha version…)