Thanks for additional information.
You notice that text is not formatted in comments, so I reformat here:
Where is result row (a cell in which table) ? I suppose it is in the table of ResultsTableViewController ? Do I understand correctly that this table can contain either Decks or cards ?
Yep, right, results are cells in ResultsTableViewController, there might be decks or cards, depending on scope.
Is behaviour different for decks or cards, or is it the same "nothing happens" ?
Yes, for both nothing happens.
Did you check identifiers are effectively "cardsVC" and "cardDetailVC" (with same upper/lowercase) -
Yes, I checked. This is the output:
navigation controller is nil,
I also tried to embed ResultsTableViewController with navigation controller, but it didn't help.
print("didSelect scope", scope, "indexPath", indexPath)
didSelect scope Optional("Decks") indexPath [0, 0]
print("cardsVC instantiated, with selectedDeck", cardsVC.selectedDeck)
print("self.parent?.navigationController", self.parent?.navigationController)
Decks cardsVC instantiated, with selectedDeck Optional(Deck { _id = 60e98c5da7d8064df3298f68; name = Greetings; dateCreated = 2021-07-10 12:02:37 +0000; layout = frontToBack; autoplay = 0; cards = List <0x283afcfc0> ( [0] Card { _id = 60e98c63a7d8064df3298f6c; front = hello; back = ; dateCreated = 2021-07-10 12:02:43 +0000; audioName = (null); }, [1] Card { _id = 60e98c6aa7d8064df3298f6d; front = good evening; back = ; dateCreated = 2021-07-10 12:02:50 +0000; audioName = (null); } ); })
self.parent?.navigationController nil
didSelect scope Optional("Cards") indexPath [0, 0] Cards cardDetailVC instantiated, with selectedCard Optional(Card { _id = 60e98c6aa7d8064df3298f6d; front = good evening; back = ; dateCreated = 2021-07-10 12:02:50 +0000; audioName = (null); })
self.navigationController nil
Now the cause:
ResultsTableViewController is not part of the navigation stack, hence its navigationController is nil.
In fact, you instantiate directly:
let resultsTableController = self.storyboard?.instantiateViewController(withIdentifier: "ResultsTableViewController") as! ResultsTableViewController
You could try to add a property in
class ResultsTableViewController: UITableViewController {
var originatingController: DecksTableViewController?
var filteredDecks: Results<Deck>?
and set it when you create resultsTableController
class DecksTableViewController: UITableViewController {
private var searchController: UISearchController!
private var decks: Results<Deck>!
override func viewDidLoad() {
super.viewDidLoad()
tableView.tableFooterView = UIView()
let resultsTableController = self.storyboard?.instantiateViewController(withIdentifier: "ResultsTableViewController") as! ResultsTableViewController
resultsTableController?.originatingController = self
configureSearchController(resultsTableController)
Then call it as:
self.originatingController?.navigationController?.pushViewController(cardsVC, animated: true)
I could not test, but that should be the logic (may need some tuning though).