Ich hoffe, wenn ich die UITableView
Zeile klicken es wird eine ID zum nächsten UIView
die ID erhalten Form json Daten ich die UITableView
indexPath einige Fehler haben bekommen können nicht senden . Wie kann ich das beheben?Wie indexPath Spiel bekommen ich mit Segue senden Daten klicken
dies ist mein Code
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
}
}
}
}
was ist der Fehler? –