I am using FUIIndexTableViewDataSource as explained on https://github.com/firebase/FirebaseUI-iOS/tree/master/FirebaseDatabaseUI.
I want to show a detail view controller when an item is tapped, but I don't know how to get the reference, key or data when preparing for the segue.
My code:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showDetail" {
if let indexPath = self.tableView.indexPathForSelectedRow {
// HELP: How do I access the firebase reference, index, and data from here?
}
}
}
And in a setupDatabase() function I have set up the data source.
self.dataSource = self.tableView.bind(
toIndexedQuery: chatKeysRef,
data: chatDataRef,
delegate: self,
populateCell: {
(tableView, indexPath, dataSnapshot) in
let cell = tableView.dequeueReusableCell(withIdentifier: "Chat", for: indexPath);
if (dataSnapshot == nil) {
cell.textLabel?.text = "";
cell.detailTextLabel?.text = "";
return cell;
}
cell.textLabel?.text = "hello world"
if (dataSnapshot!.hasChild("most_recent_message")) {
cell.detailTextLabel?.text = dataSnapshot?.childSnapshot(forPath: "most_recent_message").value as? String;
}
return cell;
});
FUIIndexTableViewDataSource doesn't seem to have any public properties or methods that would help me: https://github.com/firebase/FirebaseUI-iOS/blob/master/FirebaseDatabaseUI/FUIIndexTableViewDataSource.h
The Readme.md makes reference to FUIDataSource but that seems not to be present in FUIIndexTableViewDataSource.
Data for the selected row can be read like this