Json 如何获得indexPath匹配我单击segue发送数据

Json 如何获得indexPath匹配我单击segue发送数据,json,swift,uitableview,segue,Json,Swift,Uitableview,Segue,我希望当我单击UITableView行时 它将向下一个UIView ID获取表单json数据 我无法获取UITableViewindexPath 我有一些错误。 我怎样才能解决这个问题 这是我的密码 func get(){ let url = NSURL(string: "http://test.php?id=01") let data = NSData(contentsOfURL: url!) values = try! NSJSONSerialization.JSON

我希望当我单击
UITableView
行时 它将向下一个
UIView
ID获取表单json数据 我无法获取
UITableView
indexPath 我有一些错误。 我怎样才能解决这个问题

这是我的密码

func get(){
    let url = NSURL(string: "http://test.php?id=01")
    let data = NSData(contentsOfURL: url!)
    values = try! NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers) as! NSArray
    tableView1.reloadData()
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return values.count;
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! SpecialCell
    let maindata = values[indexPath.row]
    cell.name.text = maindata["product"] as? String
    cell.vintage.text = maindata["vintage"] as? String

    ID = maindata["ID"] as? String


    return cell;
}

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!){
    if segue.identifier == "showWineDetail"{
        if indexPath = self.tableView1.indexPathForSelectedRow{
            let destination = segue.destinationViewController as! ViewController
            destination = self.ID
        }
    }
}
}

在目标中创建(ViewController)变量ID:String=“”

错误是什么?
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! SpecialCell
    let maindata = values[indexPath.row]
    cell.name.text = maindata["product"] as? String
    cell.vintage.text = maindata["vintage"] as? String

    return cell;
}

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!){
    if segue.identifier == "showWineDetail"{
        if let indexPath = self.tableView1.indexPathForSelectedRow{
            let destination = segue.destinationViewController as! ViewController
            let maindata = values[indexPath.row]
            destination.ID = maindata["ID"] as? String
        }
    }
}