Ive built a side menu that pop out when you click on a bar button item, After you click on one of the menu options the view controller load up with the right data but the bar button item is disappeared. so i made some research and i found out that the problem is my segue destination, My segue destination is the view controller and not the navigation controller so i try to change my code ending up with this:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let cell = sender as? UITableViewCell{
let i = tableView.indexPath(for: cell)!.row
if segue.identifier == "viewController"{
let nav = segue.destination as! UINavigationController
let addEventViewController = nav.topViewController as! ViewController
addEventViewController.varView = i
}
}
}
And now i'm getting this error:
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)