Le passage des données à partir de tableView à ViewController en Swift

J'ai une Application que je suis en train d'adapter exactement comment je veux

J'ai été à la suite d'un Youtube tutoriel de Seemu Apps pour le faire, mais j'ai besoin de terminer l'ajout d'une option ViewController

Cette application a 2 tableViews montrant des véhicules et si on clique sur une ligne de la première tableView puis la deuxième tableView va nous montrer une liste de tous les véhicules sélectionnés.

Voici ce que nous avons jusqu'à maintenant: (lien de l'image , parce que je n'ai pas eu dix points de réputation sur stackOverFlow)

http://subefotos.com/ver/?65ba467040cb9280e8ec49644fd156afo.jpg

Tous est en cours d'exécution parfaite, mais je veux être en mesure d'afficher des informations dans une option detailViewController (étiquette avec une description détaillée de chaque véhicule et une plus grande image de cette dernière ) en fonction de quel véhicule il suffit de cliquer dans la secondTableViewControlle (ou modelViewController dans l'App) exactement comment j'ai été suivant dans le tutoriel entre tableViews

je sais que nous avons besoin pour le transfert de données par le biais de la méthode prepareForSegue , j'ai bien compris ce faisant les étapes décrites dans le tutoriel, mais quand nous avons 2 tableviewControllers

Par exemple : si nous voulons afficher une dernière viewController avec les informations de la Ferrari 458 et une grande image de cette voiture

Que devons-nous faire exactement pour afficher les informations de chaque véhicule?

PD : je suis débutant dans le monde de la programmation, j'aurais peut-être besoin de le voir d'une manière très simple

L'ensemble du code:

ViewController.swift
import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
var selMake = String()
@IBOutlet var tableView : UITableView!
var transportData : [String] = ["Car", "Plane", "Motorcycle", "Truck" , "Train", "Bicycle" , "Helicopter"]
//////////////////////////////////////////

//viewDidLoad    
    override func viewDidLoad() {
super.viewDidLoad()
//Register custom cell

var nib = UINib(nibName: "customCell", bundle: nil)
tableView.registerNib(nib, forCellReuseIdentifier: "cell")
}
//Numbers of rows in Section        
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.transportData.count
}
//cellForRowAtIndexPath        
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
/////Static Cell (no valid for custom cells)

/*
var cell : UITableViewCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as UITableViewCell
cell.textLabel?.text = self.transportData[indexPath.row]
return cell
*/
var cell:customCellTableViewCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as customCellTableViewCell
cell.lblTrans.text = transportData[indexPath.row]
cell.imgTrans.image = UIImage (named: transportData[indexPath.row])
return cell
}      
//height        
    func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 90
}
//didSelectRowAtIndexPath        
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {            
println("Fila \(transportData[indexPath.row]) seleccionada")            
selMake = transportData[indexPath.row]            
performSegueWithIdentifier("modelView", sender: self)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if(segue.identifier == "modelView") {                                
var vc = segue.destinationViewController as modelViewViewController
vc.selMake = selMake                            
}            
}
import UIKit
class customCellTableViewCell: UITableViewCell {
@IBOutlet weak var imgTrans: UIImageView!
@IBOutlet weak var lblTrans: UILabel!
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
    }    
}
import UIKit
class modelViewViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
//////////////////////////////////               
    var selMake = String()       
var tableData : [String] = []
@IBOutlet var tableView: UITableView!
//////////////////////////////////
    override func viewDidLoad() {
super.viewDidLoad()
//Register custom cell

var nib = UINib(nibName: "customCell2", bundle: nil)
tableView.registerNib(nib, forCellReuseIdentifier: "cell")
switch selMake {
case "Car" :
tableData = ["Ferrari 458", "La Ferrari"]
case "Plane" :                
tableData = ["Iberia"]
case "Motorcycle" :                
tableData = ["Kawasaki Ninja", "Yamaha Aerox"]
case "Truck" :                
tableData = [ "Camion transporte"]
case "Train" :                
tableData = [ "Ave" ]
case "Bicycle" :                
tableData = ["BMX"]   
case "Helicopter" :                
tableData = ["HelicopteroCombate"]
default:
println("Sel Make \(selMake)")                                                
}            
self.tableView.reloadData()                        
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
//Dispose of any resources that can be recreated.
    }
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.tableData.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
/* var cell : UITableViewCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as UITableViewCell
cell.textLabel?.text = self.tableData[indexPath.row]
return cell*/
var cell:customCell2TableViewCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as customCell2TableViewCell
cell.lbl2text.text = self.tableData[indexPath.row]
cell.img2image.image = UIImage (named: tableData[indexPath.row])
return cell            
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
println("Row \(indexPath.row)selected")
performSegueWithIdentifier("detailView", sender: self)  
}
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 90
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if(segue.identifier == "detailView") {
var vc = segue.destinationViewController as DetailViewController 
}      
}
import UIKit
class customCell2TableViewCell: UITableViewCell {                
@IBOutlet var lbl2text: UILabel!
@IBOutlet var img2image: 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
    }    
}
import UIKit    
class DetailViewController: UIViewController {                
@IBOutlet var imgDetail: UIImageView!                
@IBOutlet var lblDetail: UILabel!
override func viewDidLoad() {
super.viewDidLoad()   
//Do any additional setup after loading the view.
    }
toute suggestion? =(

OriginalL'auteur FactorJose | 2015-01-20