Given:
In App module:
extension UINavigationController {
@objc func popToViewControllerType(_ viewControllerType: UIViewController.Type, animated: Bool) -> [UIViewController]? { ... }
}
In test module:
class TestNavigationController: UINavigationController {
func popToViewControllerType(_ viewControllerType: UIViewController.Type, animated: Bool) -> [UIViewController]? { ... }
}
When called in a test, the extension implementation is always called. When both definitions are marked @objc
, the compiler produces a duplicate definition error. When neither has @objc
, it compiles, but produces the same behavior, where the extension is always called.
Is this a Swift or Obj-C behavior? Any way to override the extension implementation from a subclass?