title: How to dynamically indicate the properties of a button in a SWIFT function
body: <p>I am creating a function that changes the background colors of a label but since the label could be one of many, I need to pass the label name and them construct it in the function.  Something like:</p>
  
  <pre><code>selectedLabel.backgroundColor = UIColor(red: 0.1, green: 0, blue: 0, alpha: 0.1)
  </code></pre>
  
  <p>where <strong>selectedLabel</strong> is the name of the label being passed. Currently I get an error on the <code>selectedLabel</code> that "Value of type '<code>String</code>' has no member"</p>
  
  <p>See the code below:</p>
  
  <pre><code>@IBAction func btn1B(sender: AnyObject)
  {
  
      let passedLabel = "btn1B"
      changeColor (passedLabel)
  
  }
  </code></pre>
  
  <p>/**************************************************/</p>
  
  <pre><code>func changeColor (selectedLabel: String)
  {
      switch nextColor
      {
      case 0: selectedLabel.backgroundColor = UIColor(red: 0.1, green: 0, blue: 0, alpha: 0.1)
      case 1: selectedLabel.backgroundColor = UIColor(red: 0.2, green: 0, blue: 0, alpha: 0.2)
      case 2: selectedLabel.backgroundColor = UIColor(red: 0.3, green: 0, blue: 0, alpha: 0.3)
      case 3: selectedLabel.backgroundColor = UIColor(red: 0.4, green: 0, blue: 0, alpha: 0.4)
      case 4: selectedLabel.backgroundColor = UIColor(red: 0.5, green: 0, blue: 0, alpha: 0.5)
      case 5: selectedLabel.backgroundColor = UIColor(red: 0.6, green: 0, blue: 0, alpha: 0.6)
      case 6: selectedLabel.backgroundColor = UIColor(red: 0.7, green: 0, blue: 0, alpha: 0.7)
      case 7: selectedLabel.backgroundColor = UIColor(red: 0.8, green: 0, blue: 0, alpha: 0.8)
      default: print("end of colors")
      }
  </code></pre>
  
  <p>}</p>