I'm having a table view that contains this prepareForSegue function:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let upcoming: CategoryDeviceViewController = segue.destination as! CategoryDeviceViewController
let myindexpath = self.MainPageTableView.indexPathForSelectedRow
let titleString = self.CategoryTitle.object(at: ((myindexpath as NSIndexPath?)?.row)!) as? String
upcoming.titlestring = titleString
self.MainPageTableView.deselectRow(at: myindexpath!, animated: true)
}
To get the title from 6 cells and save them to next view in nvigational bar title.
In this view that contains the prepare for segue function there's a button in navigational bar that moves to another (third) view controller!
Whenever I click on that button the app crashes on this line:
let upcoming: CategoryDeviceViewController = segue.destination as! CategoryDeviceViewController
I know the reason of the error but how can I solve it?