Hi David, I know i sort of closed off this topic but the idea of not having a search functionality in my app haunts me, so I decided to go forward with your advice since instantiating is impossible.
So in my didSelectRow()
delegate method, I have the following code,
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
let costData = hitsSource!.hit(atIndex: indexPath.row)!.eventCost
let dateData = hitsSource!.hit(atIndex: indexPath.row)!.eventDate
let nameData = hitsSource!.hit(atIndex: indexPath.row)!.eventName
let gradesData = hitsSource!.hit(atIndex: indexPath.row)!.forEventGrades
let vc = self.presentingViewController as! TeacherTableViewController
vc.nameTheEvent = nameData
vc.dateTheEvent = dateData
vc.costTheEvent = costData
vc.gradeTheEvent = gradesData
self.presentingViewController?.performSegue(withIdentifier: Constants.Segues.fromSearchToSchoolEventDetails, sender: self)
}
So i customized my struct and my index to have more data of the event as you said I should. I put the proper presentingVC, the VC that you set up the search controller in, and created a variable for that and transferred the variables as well. I created those four variables in the presentingVC with String data types so I can use the variables created in my delegate method.
Now the issue is that for the segue, I created as segue from TeacherTableVC (the presentingVC) and connected it to my DestinationVC, it’s registered and everything but when I click on the hit cell, it crashes and says, the presentingVC has no segue identifier with the segue identifier name I gave it which I get confused about.
I will also display the code in my presentingVC specifically the prepare
function.
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == Constants.Segues.fromSearchToSchoolEventDetails {
let vc = segue.destination as! SchoolDetailsViewController
vc.title = nameTheEvent
vc.dateEditableTextF.text = dateTheEvent
vc.costEditableTextF.text = costTheEvent
vc.gradesEditableTextF.text = gradeTheEvent
}
}
So after having all this I thought the code would work successfully but it crashed instead, if there’s anything you can point out that’s wrong in my code, that would be great. Thanks.