I've a BaseController (BVC) where I've started to listen to notifications in viewWillAppear & stop listening to them at viewWillDisappear methods.
BVC
- CustomView (Notification received updates this VC)
Now I've subclassed 4 different controllers from BVC.
BVC
|-- FirstVC (FVC)
|-- SecondVC (SVC)
|-- ThirdVC (TVC)
Now, I've one TarBarController which has these 3 VC's as its items via a NavigationViewController (NVC)
TabBarController
|- NVC->FVC
|- NVC->SVC
|- NVC->TVC
My problem is, I've sending across a playWillBegin notification from a Singleton object which is a AVPlayer instance. Notification is received from the VC which is active on top, but if I dont switch tabs quickly the notifications are not received in the other controllers.
I also read in SO, that other VC are not instantiated and that is reason the notifications are not received. But I can't use init method in VC because its asking me to use initWithaCoder
My project is all code and does not use storyboard etc. So my TabBarController is a swift class, has the items there and TabBarController instance in AppDelegate
EDIT 1: Relevant SO QA links Link1 Link2
EDIT 2: To clarify why I'm not being able to add anything in init() method of VC BaseViewController - Snippet
init() {
super.init() //Please refer image for error message
}
required init?(coder aDecoder: NSCoder) {
}
TabBarController
class TabBarController: UITabBarController, UITabBarControllerDelegate {
override func viewDidLoad() {
tabBar.tintColor = UIColor.whiteColor()
self.delegate = self
let FNVC = UINavigationController(rootViewController: FVC())
//Other initialization code
let SNVC = UINavigationController(rootViewController: SVC())
//Other initialization code
let TNVC = UINavigationController(rootViewController: TVC())
//Other initialization code
viewControllers = [FNVC, SNVC, TNVC]
}
}