title: Is it possible to use a variable to replace a reference
body: <p>VC1 has three buttons 'Card1', 'Card2', and 'Card3', each segues to VC2 which has four buttons with Images '2s', '2h', '2c' and '2d'</p>
  
  <p>segue.identifiers are Card1, Card2, Card3</p>
  
  <p>buttons '2s', '2h', '2c' and '2d' all unwind segue and should replace original segue-caller button image with image from Images.xcassets named: '2s', '2h', '2c' or '2d' according to which button selected in VC2</p>
  
  <p><strong>CardSelected</strong> identifies which VC2 button called unwindSegue.</p>
  
  <p>and unwind segue-identifiers are 1, 2, 3, 4 respectively with a 5th "clear button segue-identifier as 0. </p>
  
  <p>images are declared in array Cards (VC1) and unwindSegue-identifier is used to call the index.</p>
  
  <p><strong>Is it possible to consolidate this code...</strong></p>
  
  <p><strong>EDIT FULL CODE AS IS</strong></p>
  
  <p>VC1</p>
  
  <pre><code>import UIKit
  
  class VC1: UIViewController {
  
  @IBOutlet weak var Card1: UIButton!
  @IBOutlet weak var Card2: UIButton!
  @IBOutlet weak var Card3: UIButton!
  
  let Cards: [UIImage] = [UIImage(named: "Default")!, UIImage(named: "2s")!,UIImage(named: "2h")!,UIImage(named: "2c")!,UIImage(named: "2d")!,]
  
  var caller = ""
  var Index2 = Int()
  
  override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
          let KVC = segue.destinationViewController as VC2
      KVC.source = segue.identifier!}
  
  @IBAction func unwind(unwindSegue: UIStoryboardSegue){
      Card1.setImage(Cards[Index2], forState: UIControlState.Normal)
      //I want to replace Card1.setImage with (UIButton with name = "caller").setImage
      //instead of having
      //if caller = "Card1" {Card1.setImage(Cards[Index2], forState: UIControlState.Normal)} else if caller = "Card2" {Card2.setImage(Cards[Index2], forState: UIControlState.Normal)} else if caller = "Card3" {Card3.setImage(Cards[Index2], forState: UIControlState.Normal)}
  }
  
  @IBAction func text(sender: AnyObject) {
      println(caller)
      println(Index2)
  }
  </code></pre>
  
  <p>}</p>
  
  <p>VC2 </p>
  
  <pre><code>import UIKit
  
  class VC2: UIViewController {
  
  var CardSelected = ""
  var source = ""
  
  override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
      CardSelected = segue.identifier!
      var Index:Int = CardSelected.toInt()!
      let DVC = segue.destinationViewController as VC1
      DVC.caller = source
      DVC.Index2 = Index
  
  }
  }
  </code></pre>
  
  <p><strong>In VC1, I want to somehow make Card1.setImage(Cards[Index2], forState: UIControlState.Normal) as (X).setImage(Cards[Index2], forState: UIControlState.Normal) where (X) is replaced at code with current 'caller'</strong></p>
  
  <p>I thought to place UIButtons in an array and call it from the array but</p>
  
  <pre><code>let CardCaller: [UIButton] = [UIButton(Card1)!, UIButton(Card2)!, UIButton(Card3)!]  //in VC1
  </code></pre>
  
  <p>brings error: 'VC1.Type' does not have a member named 'Card1'</p>