0

I have an UITableView with a custom cell that triggers a segue when selected. No problems there. I also have a search bar that is working fine with sorting. The problem begins when the searchDisplayController.searchResultsTableView is displayed, and I select a cell within that. didSelectRowAtIndexPath fires without a problem.

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

which then fires performSegueWithIdentifier without a hitch

override func performSegueWithIdentifier(identifier: String?, sender: AnyObject?) {
    println("Perform segue fired")
}

However, prepareForSegue is never called.

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

    if segue.identifier == "doneSegue" {
        println("Done Segue")
    }

    if segue.identifier == "details" {
        if let destinationVC = segue.destinationViewController as? CoffeeDetailViewController {
            if let index = self.journalTable.indexPathForSelectedRow() {
                // Sets an object to hold the contents of the specific cell that was tapped
                let parametersForRow = coffeeEntry[index.row]
                let attributes: Dictionary = parametersForRow.entity.attributesByName as Dictionary
                let parameterDictionary: Dictionary = parametersForRow.dictionaryWithValuesForKeys(attributes.keys.array)
                println("Parameters: \(parametersForRow)")
                destinationVC.parameterDictionary = parameterDictionary
            }
        }
    }
}

I have a feeling I'm making a rookie mistake and I'm just not seeing something. Any ideas?

EDIT: I forgot a really important piece of information. I'm using the custom cell for the searchDisplayController.searchResultsTableView with a nib outside of storyboard. I register the nib in viewDidLoad

override func viewDidLoad() {
    super.viewDidLoad()
    self.navigationItem.leftBarButtonItem?.title = "Back"

    var nib = UINib(nibName: "CoffeeTableViewCell", bundle: nil)
    searchDisplayController?.searchResultsTableView.registerNib(nib, forCellReuseIdentifier: cellIdentifier)
}
Coltrane
  • 165
  • 1
  • 2
  • 12
  • You have see it this http://stackoverflow.com/questions/26236975/prepareforsegue-not-called-from-custom-uitableviewcell – Victor Sigler Mar 30 '15 at 20:50
  • 1
    One way I might debug this is to determine where exactly it's not performing by putting `println()` statements within the second segue call and see what's triggered. One before the `if let destinationVC = ...` and one before the `if let index = ...`. Depending on which (in any) are triggered, you'd narrow down whether or not the segue is set up properly or if the code within the block is set up properly. – Aaron Mar 30 '15 at 20:52
  • I've set breakpoints throughout the prepareForSegue method. It's never called, at all. – Coltrane Mar 30 '15 at 21:02

0 Answers0