Konsy Konsy - 1 year ago 70
iOS Question

Could not cast value of type 'UITabBarController' Swift

I'm aware questions have been asked which are the same as mine but I did in fact try suggestions and got nothing, so i'd see if anyone could work it out from my code here.

I have a LoginViewController which is known as WelcomeVC in that i have a button which signs the user into the app, once they've signed in if everything goes ok it loads the TabBarVC which has 5 UIViewControllers connected to it through relationship 'viewcontrollers' however this was working fine literally 20 minutes ago but for some reason when i went to test this on the simulator to show a client it seemed to crash when trying to sign in.

The code I have is as followed:

@IBAction func signUserIn(sender: AnyObject) {

FIRAuth.auth()?.signInWithEmail(usernameTF.text!, password: passwordTF.text!, completion: { (user, error) in
if error != nil
print("email/pass is wrong!")
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("tBVC") as! TabBarVC
self.presentViewController(nextViewController, animated:true, completion:nil)


This worked fine before and loads the next view programatically, not through any segue's. Any suggestions to why it's suddenly stopped working and any idea on how to fix it?

this is the error code:

Could not cast value of type 'UITabBarController' (0x1119548b0) to 'LT_Apps.TabBarVC' (0x10e4e9980).


You didn't set the class of UITabBarController. Like this: enter image description here

1. Did TabBarVC class exist?
2. Did TabBarVC inherit UITabBarController?
If both is yes,just copy paste TabBarVC to its class item. And build it!