Reputation: 1226
I am new to iOS, I am trying to assign some values in customTab Controller I created. After I present the tabController , the values are not being the original values, what I sent. Please help me, where I am doing wrong.
let tabBarController = CustomTabBarController()
tabBarController.hideStatus = self.hideStatus
tabBarController.fromLanguageChange = self.fromLanguageChanged
tabBarController.testInt = 1234;
FF_DataPersistenceUtils.setIsFromNotification(isFromNotification: !self.isFromNotification)
let navController = UINavigationController(rootViewController: tabBarController)
self.present(navController, animated: false, completion: nil)
Custom tab controller .
class CustomTabBarController: UITabBarController {
var hideStatus : Bool = false;
var testInt : Int = 1;
override func viewDidLoad() {
super.viewDidLoad()
print("hide status in custom tab : \(self.hideStatus)") // false
print("testInt values \(self.testInt)") // 1
}
}
Upvotes: 0
Views: 168
Reputation: 2714
Try using instantiateViewControllerWithIdentifier
function to instantiate the viewController
let storyboard = UIStoryboard(name: yourStoryBoardName, bundle: nil)
let tabBarController = storyboard.instantiateViewController(withIdentifier :viewControllerName) as! CustomTabBarController
tabBarController.hideStatus = self.hideStatus
tabBarController.fromLanguageChange = self.fromLanguageChanged
tabBarController.testInt = 1234;
FF_DataPersistenceUtils.setIsFromNotification(isFromNotification: !self.isFromNotification)
let navController = UINavigationController(rootViewController: tabBarController)
self.present(navController, animated: false, completion: nil)
Upvotes: 1