title: Send data from TableView to DetailView Swift
body: <p>I'm trying to do maybe one of the simplest and more confusing things for me until now
  I wanna develop my own App , and in order to do it I need to be able to passing some information depending of which row user click (it's Swift lenguage)</p>
  
  <p>We have a RootViewController(table view) and a DetailViewController (with 1 label and 1 image)
  <img src="https://i.stack.imgur.com/BcQpW.jpg" alt="enter image description here"></p>
  
  <p>(our view)</p>
  
  <p>Here is the code: </p>
  
  <pre><code>@IBOutlet weak var tableView: UITableView!
  
  
  var vehicleData : [String] = ["Ferrari 458" , "Lamborghini Murcielago" , "Bugatti Veyron", "Mercedes Benz Biome"]
  
  override func viewDidLoad() {
      super.viewDidLoad()
      // Do any additional setup after loading the view, typically from a nib.
  
      var nib = UINib(nibName: "TableViewCell", bundle: nil)
  
      tableView.registerNib(nib, forCellReuseIdentifier: "cell")
  
  
  
  }
  
  func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
      return vehicleData.count
  }
  
  
  
  func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
  
  
      let cell:TableViewCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as TableViewCell
  
      cell.lblCarName.text = vehicleData[indexPath.row]
  
      cell.imgCar.image = UIImage(named: vehicleData[indexPath.row])
  
      return cell   
  }
  
  func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
  
      performSegueWithIdentifier("DetailView", sender: self)
  }
  
   override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
  
      if(segue.identifier == "DetailView") {
  
          var vc = segue.destinationViewController as DetailViewController
  
      }
  
  }
  
  func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -&gt; CGFloat {
      return 100
  }
  </code></pre>
  
  <p>Custom TableViewCell class (has a xib File with cell)</p>
  
  <pre><code>class TableViewCell: UITableViewCell {
  
  
  @IBOutlet weak var lblCarName: UILabel!
  
  @IBOutlet weak var imgCar: UIImageView!
  
  override func awakeFromNib() {
      super.awakeFromNib()
      // Initialization code
  }
  
  override func setSelected(selected: Bool, animated: Bool) {
      super.setSelected(selected, animated: animated)
  
      // Configure the view for the selected state
  }
  
  class DetailViewController: UIViewController {
  
  
  
      @IBOutlet weak var lblDetail: UILabel!
  
      @IBOutlet weak var imgDetail: UIImageView!
  
      override func viewDidLoad() {
          super.viewDidLoad()
      }
  </code></pre>
  
  <p>The question is: </p>
  
  <p>if user click Ferrari 458 , the lblDetail in DetailViewController would show: Ferrari 458 is a super car which is able to reach 325 km/ h ...... (whatever we want)
   and imgDetail would be able to show an image (whatever we want) of the car</p>
  
  <p>If user click Bugatti Veyron now the lblDetail show us: Bugatti Veyron is a perfect and super sport machine. It's one of the fastest car in the world....</p>
  
  <p>imgDetail show us an image of this car</p>
  
  <p>Same thing with all cars depending which row we have clicked</p>
  
  <p>I know the work is around prepareForSegue func in first View Controller but i was trying a lot of different ways to make it possible and anything runs ok</p>
  
  <p>How we can do this???</p>