How do you make it so that a random generated number in an arc4random() set is never repeated. For example, in arc4random(100) in 1 is chosen, it will never be brought up again.
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var card: UIImageView!
@IBOutlet weak var nextButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func nextCardTapped(sender: UIButton) {
//Edit number of cards here for the random card to show up
var randomCard = arc4random_uniform(100)
// Edit number of cards here for the random card to show up
var randomCardString:String = String(format: "card%i", randomCard)
self.card.image = UIImage(named: randomCardString)