I am trying to programmatically install the view controllers of my custom TabBarController:
import UIKit class TabBarViewController: UITabBarController, UITabBarControllerDelegate { var cameraViewController: UIViewController? var profileViewController: UIViewController? override func viewDidLoad() { super.viewDidLoad() self.delegate = self
But with the line
self.viewControllers = [cameraViewController, profileViewController] as! [AnyObject]?
I get an error that I cannot convert [UIViewController] to [AnyObject?]
and with the line
self.setViewControllers(controllers as! [AnyObject], animated: true)
I get an error message:
Cannot invoke 'setViewControllers' with an argument list of type '([AnyObject], animated: Bool)'
My problem is with AnyObject and typecasting, I think.
source share