我遇到此错误的问题。如果继续我的segue。有没有办法来解决这个问题。非常感谢任何和所有帮助。
这是我的视图控制器
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
***let rvc = segue.destinationViewController as! WebViewController***
rvc.currentCollege = currentCollege
}
继承我的班级:
import Foundation
class College {
var webView = String()
var name = String()
var description = String()
var location = String()
var numberOfStudents = String()
var image = String()
init(Name n: String,Description d: String,Location l: String,NumberOfStudents s: String,Image i:String, WebView w: String) {
name = n
description = d
location = l
numberOfStudents = s
image = i
webView = w
}
init(){
name = ""
description = ""
image = ""
webView = ""
}
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let currentCell = tableView.dequeueReusableCellWithIdentifier("myCell")!
let currentCollege = collegeArray[indexPath.row]
currentCell.textLabel!.text = currentCollege.name
currentCell.detailTextLabel?.text = currentCollege.location
return currentCell
}
答案 0 :(得分:2)
我猜测destinationViewController不是WebViewController。也许WebViewController嵌入在导航控制器中你可以做类似的事情:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let rvc = segue.destinationViewController as? WebViewController {
rvc.currentCollege = currentCollege
}
}
避免在prepareForSegue中强制执行强制转换。