Is it possible to add 3d touch to a table cell that gets the data of the new controller from Firebase?
I have this code below as an extension when I just press on the table cell it moves to the next controller fine and gets the correct data from Firebase, but when I use peek and pop I get a crash saying that the variable is not available. If I put static text in instead of getting it from the firebase array I get the same as well.
extension myVC: UIViewControllerPreviewingDelegate {
func previewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController) {
present(viewControllerToCommit, animated: true)
}
private func createDetailViewControllerIndexPath(indexPath: IndexPath) -> MainInfoVC {
let dataPop = self.posts[indexPath.row]
let infoPop = dataPop
let storyboard = UIStoryboard(name: "ShowAndComments", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "MainInfoVC") as? MainInfoVC
vc?.descriptionLabel.text = infoPop.desc
return vc!
}
func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
guard let indexPath = tableView.indexPathForRow(at: location) else { return nil }
let detailViewController = createDetailViewControllerIndexPath(indexPath: indexPath)
return detailViewController
}
}
I also get a crash if I change this To..
vc?.descriptionLabel.text = "Some Text"
myApp was compiled with optimization - stepping may behave oddly; variables may not be available. (lldb)