Swift PrepareForSegue 错误线程 1:EXC_BREAKPOINT(代码=EXC_ARM_BREAKPOINT,子代码=0xdefe
Swift PrepareForSegue ERROR Thread 1: EXC_BREAKPOINT(code=EXC_ARM_BREAKPOINT, subcode=0xdefe
我在尝试编译 PrepareForSegue 函数时遇到了很大的问题:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
if segue.identifier == "findMap" {
let MapViewController = segue.destinationViewController as UIViewController
if sender as UITableView == self.searchDisplayController!.searchResultsTableView {
let indexPath = self.searchDisplayController!.searchResultsTableView.indexPathForSelectedRow()!
let destinationTitle = filteredDepartments[indexPath.row].name
MapViewController.title = destinationTitle
} else {
let indexPath = self.tableView.indexPathForSelectedRow()!
let destinationTitle = departments[indexPath.row].name
MapViewController.title = destinationTitle
}
}
}
错误在 "trap" 行的线程部分打开:
--> 0x2f6e18: 陷阱
错误码如上:
--> 线程 1: EXC_BREAKPOINT(code=EXC_ARM_BREAKPOINT, subcode=0xdefe
我认为错误在这一行:
if sender as UITableView == self.searchDisplayController!.searchResultsTableView {
但是我不知道怎么解决,所以请帮助我...
很难说出您的代码的含义,但我猜您的意思是:
if sender === self.searchDisplayController!.searchResultsTableView {
请注意使用三等号运算符表示 "is the same object as"。
我在尝试编译 PrepareForSegue 函数时遇到了很大的问题:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
if segue.identifier == "findMap" {
let MapViewController = segue.destinationViewController as UIViewController
if sender as UITableView == self.searchDisplayController!.searchResultsTableView {
let indexPath = self.searchDisplayController!.searchResultsTableView.indexPathForSelectedRow()!
let destinationTitle = filteredDepartments[indexPath.row].name
MapViewController.title = destinationTitle
} else {
let indexPath = self.tableView.indexPathForSelectedRow()!
let destinationTitle = departments[indexPath.row].name
MapViewController.title = destinationTitle
}
}
}
错误在 "trap" 行的线程部分打开:
--> 0x2f6e18: 陷阱
错误码如上:
--> 线程 1: EXC_BREAKPOINT(code=EXC_ARM_BREAKPOINT, subcode=0xdefe
我认为错误在这一行:
if sender as UITableView == self.searchDisplayController!.searchResultsTableView {
但是我不知道怎么解决,所以请帮助我...
很难说出您的代码的含义,但我猜您的意思是:
if sender === self.searchDisplayController!.searchResultsTableView {
请注意使用三等号运算符表示 "is the same object as"。