title: Randomizing through number range
body: <p>I'm trying to get this part of the app to work were the user clicks a button and a label prints a randomly generated number between 1-12. I've been able to successfully do that, but I also want it to not repeat any random numbers that have already been printed.</p>
  
  <p>What I've tried doing is putting any printed number into an array, and then checking the array each time it generates a new number.</p>
  
  <p>I've gotten it to work in the Playground, but cannot get it working with a real project.</p>
  
  <p>Here is the code for my project.</p>
  
  <pre><code>    var usedNumbers = [Int]()
      var randomConv = 0
  
  func randomize() {
      lblRandom.text = "\(arc4random_uniform(12) + 1)"
      randomConv = Int(lblRandom.text!)!
  }
  
  @IBAction func btnRandomPressed(sender: AnyObject) {
      randomize()
      if usedNumbers.contains(randomConv) {       
          randomize()
  
      } else {    
          usedNumbers.append(randomConv)
  
      }
  
      if usedNumbers.count == 12 {
          btnRandom.hidden = true
      } 
  }
  </code></pre>
  
  <p>And here is the code from my playground.</p>
  
  <pre><code>var lblRandom = "\(arc4random_uniform(12) + 1)"
  var randomConv = 0
  var usedNumbers = [Int]()
  
  func randomize() {
  lblRandom = "\(arc4random_uniform(12) + 1)"
  randomConv = Int(lblRandom)!
  }
  
  repeat {
  randomize()
  
  if usedNumbers.contains(randomConv) {
      randomize()   
  } else {
      usedNumbers.append(randomConv)
      print(lblRandom)
  }
  
  } while usedNumbers.count &lt; 12
  </code></pre>