title: Automatically create Swift UILabels programmatically
body: <p>I want to create UILabels in swift automatically based on need. I.e If my data base request returns 4 values, I want 4 labels, if it returns 1 value, i want 1 label..ect.</p>
  
  <p>So far i have the code below, but it displays my data(Strings in an array on parse) on-top of each other in one label. I need a dynamic way to create new labels with different names, but am not sure how to do this. Currently this is my code. I have a 'spacer' variable that i hoped would push the next retrieved data in a label 50px below but it just pushes all the data in the same UILabel below by 50. </p>
  
  <pre><code>for comments in object["Comments"] as NSArray {
       var counter = ""   
       println(comments)
       counter = comments as String
  
         var spacer: CGFloat = 50
          var label = UILabel(frame: CGRectMake(0, 0, 200, 21))
          label.center = CGPointMake(160, 300 + spacer )
          label.textAlignment = NSTextAlignment.Center
          label.text = counter
          self.view.addSubview(label)
          spacer = spacer + 50
     }
  </code></pre>
  
  <p>I guess I need to create a new UILabel with a new name for every label(label1,label2..ect), but how can I do this dynamically, any suggestions? </p>