I've found this code to shuffle an array:
func shuffle<T>(inout array: [T]) {
for i in 1..<array.count {
let j = Int(arc4random_uniform(UInt32(i)))
(array[i], array[j]) = (array[j], array[i])
}
}
which works fine with
var arr = [1,2,3,4]
shuffle(&arr)
println(arr)
But how do I use with a NSMutableArray
?
I've tried
var PicturesArray :NSMutableArray = []
shuffle(PicturesArray)as Array
shuffle([PicturesArray])
shuffle(PicturesArray[])
but can't find any answers probably something I'm doing silly thanks for looking