Github Link - https://github.com/mateo951/ISBN-Vista-Jera-rquica-
表格视图行是存储在结构中的书籍的标题。另一个视图用它们(标题,作者,图像)搜索该书。我通过prepareForSegue方法将tableView中的值传递给详细的视图控制器。第一行没有遇到任何不便,但问题是在第二行或第三行点击表时。我的目标是在每次搜索之后,在其结构中保存的所有数据都对应于执行搜索的顺序中的每一行。
prepareForSegueMethod
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showDetail" {
if let destination = segue.destinationViewController as? DetailViewController {
let path = self.tableView.indexPathForSelectedRow?.row
// ERROR - "fatal error - Index out of range"
let arr = datosLibros[path!]
let arr1 = datosLibros2[path!]
if arr.image != nil {
destination.titleBook = arr.title
destination.author = arr.author
destination.image = arr.image!
} else {
destination.titleBook = arr1.title
destination.author = arr1.author
}
}
}
}
感谢您提供任何有关帮助的建议。我是swift的新人,因此发现了很多东西。