You can post notification to refresh the tabs based on user type, first set the observer in MainTabBarController and once the notification is fired, check the user type and refresh the tabs
extension Notification.Name {
static let refreshAllTabs = Notification.Name("RefreshAllTabs")
}
class MainTabBarController: UITabBarController, UITabBarControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(forName: .refreshAllTabs, object: nil, queue: .main) { (notification) in
//check if its a normal user or comapny user
if AppUser.shared.type == .normal {
self.viewControllers = [VC1, VC2, VC3, VC4, VC5]
} else {
self.viewControllers = [VC1, VC2, VC3, VC4]
}
}
}
deinit {
NotificationCenter.default.removeObserver(self)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
now for posting the notification whenever user type changes just call
NotificationCenter.default.post(Notification(name: .refreshAllTabs))