If the ViewController is a child of the UITabBarController that you want to access, you can simply use tabBarController property of the UIViewController, e.g., use this to change selected controller to the first one:
@IBAction func submitbutton(_ sender: UIButton) { pressed = true self.tabBarController?.selectedIndex = 0 }
So let's say that you have a custom UITabBarController subclass, e.g.:
class CustomTabBarController: UITabBarController { func acceptData(points: Int) { print(">>> Accepted: \(points)") // or do anything you need to do with it } }
Then you can pass it data as follows:
@IBAction func submitbutton(_ sender: UIButton) { pressed = true if let customTabController = self.tabBarController as? CustomTabBarController { customTabController.acceptData(points: self.points) } }
UPDATE
Since it seems that the current VC is presented by one of the tabBarController child controllers, you will have to access it through the self.presentingViewController:
@IBAction func submitbutton(_ sender: UIButton) { pressed = true if let customTabController = self.presentingViewController?.tabBarController as? CustomTabBarController { customTabController.acceptData(points: self.points) } }
UPDATE 2
Your screenshot are of a very poor quality, your explanation of the problem would require a clarification too, since it is really hard to understand what you try to do. So after the whole discussion in comments I guess this is it:
@IBAction func submitbutton(_ sender: UIButton) { pressed = true if let tabController = self.presentingViewController?.tabBarController, let viewController3 = tabController.viewControllers?.filter({ $0 is ViewController3 }).first { viewController3.acceptData(points: self.points) } }