I have a UINavigationController subclass:
fileprivate class NavController: UINavigationController {
override init(navigationBarClass: AnyClass?, toolbarClass: AnyClass?) {
super.init(navigationBarClass: navigationBarClass, toolbarClass: toolbarClass)
...
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
...
}
I instantiate this class as:
navController = NavController(navigationBarClass: nil, toolbarClass: nil)
This compiles, but fails at runtime:
AppDelegate.swift: 87: 19: fatal error: use of unimplemented initializer 'init(nibName:bundle:)' for class 'NavController'
I don't understand why init(nibName:bundle:) is being called, when I specified the keywords navigationBarClass: and toolbarClass:.
If I delete all the initialisers from my subclass, it works fine, which is confusing since overriding a method / initialiser that only calls super should be a noop.
Line 87 is the one where the class is declared. I tried stepping in with a debugger, but I can't step into UIKit code, only my code.
In case this matters, this is on iOS 10 and Swift 3.