Skip to content

Instantly share code, notes, and snippets.

@uzimith
Created May 17, 2015 00:11
Show Gist options
  • Save uzimith/42cc06776ad04d735798 to your computer and use it in GitHub Desktop.
Save uzimith/42cc06776ad04d735798 to your computer and use it in GitHub Desktop.
swift random
//: Playground - noun: a place where people can play
import UIKit
var array = [1,2,3,4,5,6]
for i in 0..<10 {
if (array.isEmpty) {
array = [1,2,3,4,5,6]
}
var index = Int(arc4random() % UInt32(array.count))
NSLog("%d",array[index])
array.removeAtIndex(index)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment