Am trying to downcast a view controller to a detail view controller but can\'t. Am using Core Data (for the first time). The error is in the prepareForSegue method and reads
It looks like you are using a navigation controller judging by your viewDidLoad()
in PatternDetailViewController
.
If PatternDetailViewController
is embedded in a UINavigatonController
then the navigation controller will be segue.destinationViewController
.
Get the PatternDetailViewController like this:
let vc: UINavigationController = segue.destinationViewController as! UINavigationController
let detailVC = vc.topViewController as! PatternDetailViewController
detailVC.pattern = self.selectedPattern