無法投型 'Google_Books_1.BookTableViewCell' 的值(0x105557600)爲 'NSIndexPath'(0x1061cb438)無法投類型TableViewCell的價值 'NSIndexPath'
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("BookCell", forIndexPath: indexPath) as!BookTableViewCell
...
}
func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
// let contact = ContactList![indexPath.row]
performSegueWithIdentifier("BookDetailSegue", sender: indexPath)
}
func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
// let contact = ContactList![indexPath.row]
performSegueWithIdentifier("BookDetailSegue", sender: indexPath)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "BookDetailSegue" {
let vc = segue.destinationViewController as! BookDetailViewController
let indexPath = sender as! NSIndexPath
vc.book = self.bookList[indexPath.row] **//error is here**
vc.index = indexPath.row
}
}
如何處理這樣的錯誤?
你確實知道你正在使用2個didDeselectRowAtIndexPath函數嗎?你不是故意使用didSelectRowAtIndexPath嗎? – Devster101