Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lldb error when trying to segue SWIFT

I was following this tutorial http://www.raywenderlich.com/76519/add-table-view-search-swift when I ran into an error. I am adding this feature into an app I was already working on. Once I am in the booths table view, I want to be able to navigate out into the main menu with a button on the navigation bar. Here is the section of code that deals with the segues.

    override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    self.performSegueWithIdentifier("BoothDetail", sender: tableView)
}

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
    if segue.identifier == "BoothDetail" {
        let BoothDetailViewController = segue.destinationViewController as UIViewController
        if sender as UITableView == self.searchDisplayController!.searchResultsTableView {
            let indexPath = self.searchDisplayController!.searchResultsTableView.indexPathForSelectedRow()!
            let destinationTitle = self.filteredBooths[indexPath.row].name
            BoothDetailViewController.title = destinationTitle
        } else {
            let indexPath = self.tableView.indexPathForSelectedRow()!
            let destinationTitle = self.booths[indexPath.row].name
            BoothDetailViewController.title = destinationTitle
        }
    }
}

}

The error is thrown while trying to use the back button on the booths list that is a direct show segue to the main conference menu. The error is on this line.

    if sender as UITableView == self.searchDisplayController!.searchResultsTableView {
like image 469
user3558131 Avatar asked Dec 01 '25 00:12

user3558131


1 Answers

You have quite a few problems. Some fatal, some just a headache.

the first headache is you are calling the same segue twice. Both functions call the same segue. Both will execute. Now if you want a double animation, okay. But since one passes data and the other does not, you may have an issue. Eliminate the didSelectRowAtIndexPath function.

In your prepareForSegue method it appears you have two different objects connected to the same segue. A searchDisplayController and a tableView. You want two separate segues. Then your if/else makes changes based on which segue was chosen:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

        if segue.identifier == "segue1" {

            //code set 1

        } else if segue.identifier == "segue2" {

            //code set 2
        }
    }
like image 67
Steve Rosenberg Avatar answered Dec 03 '25 16:12

Steve Rosenberg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!