Swift tab bar view prepareforsegue Swift tab bar view prepareforsegue swift swift

Swift tab bar view prepareforsegue


Have you checked whether the prepareForSegue in your TabBarController ever gets called?

It would never be called since the connection between a UITabBarController and its children view controllers isn't a storyboard segue. You should get a reference directly to the viewController from the UITabBarController by accessing its viewControllers collection at the index you want.

var tabBarController = segue.destination as UITabBarControllervar destinationViewController = tabBarController.viewControllers[0] as YourViewController // or whatever tab index you're trying to accessdestination.property = "some value"