Reputation: 91
I saw this lines in project, that I need to understand.
let mainControllers = self.storyboard!.instantiateViewControllerWithIdentifier("TabNavigation") as! UITabBarController
let controllers = Array(mainController.viewControllers![0..<3])
mainController.setViewControllers(controllers, animated: false)
self.presentViewController(mainController, animated: true, completion: nil)
What is the benefit of resetting view controllers? Thanks
Upvotes: 0
Views: 56
Reputation: 318824
The code is limiting mainController
to only the first 3 view controllers originally defined in the storyboard.
This code:
mainController.viewControllers![0..<3]
returns the first three elements of the original array. Then the (possibly) smaller array is used to reset the view controllers of mainController
.
Upvotes: 1