In Xcode 8 and iOS 10, I used the following code to shuffle values inside an array:
for i in 0..<appSingleton.paxArrayShared.count
{
let r = Int(arc4random_uniform(UInt32(appSingleton.paxArrayShared.count)))
// Check if you are not trying to swap an element with itself
if i != r
{
swap(&appSingleton.paxArrayShared[i], &appSingleton.paxArrayShared[r])
}
}
However, in Xcode 9 and iOS 11, I began receiving the following warning:
Simultaneous accesses to 0x########, but modification requires exclusive access.
Is there a better way to shuffle the array?
Thank you!