Reputation: 496
Actual error is Cannot convert value of type 'UIViewController' to type 'UINavigationController' in coercion
Inside the code for view controller before I segue to my nav. view controller I have the below code in my prepare
override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) {
if (segue.identifier == "SegueAfterJoin2") {
// NOTE! THIS IS TWEAKED with "as UINavigationController"
var nextViewCont:DashboardNavViewController = segue.destinationViewController as UINavigationController;
// PASS VARS FROM THIS VIEW TO NEXT
nextViewCont.passedPassword_toViewDashboard = passedPassword_toView2
nextViewCont.passedEmail_toViewDashboard = passedUsername_toView2
nextViewCont.passedUsername_toViewDashboard = passedEmail_toView2
nextViewCont.passedFocus_toViewDashboard = selectedFocus
}
}
My nav. view controller class is defined as this: class DashboardNavViewController: UIViewController {
. Should it be declared as something else?
Upvotes: 1
Views: 535
Reputation: 71854
Just replace
var nextViewCont: DashboardNavViewController = segue.destinationViewController as UINavigationController
with
var nextViewCont = segue.destinationViewController as! DashboardNavViewController
And if you want to present UINavigationController
then your DashboardNavViewController
must be a subclass of UINavigationController
which is right now subclass of UIViewController
so you can not cast it as UINavigationController
same as your error says.
And your navigation view controller class should defile like shown below:
class DashboardNavViewController: UINavigationController {
Upvotes: 2