how to override private method and call super in swift?

You must deceive the Swift compiler that such method exists. For that you can simply add an Object-C extension declaration to the bridging header of your project:

@import UIKit;

@interface UINavigationController(PrivateMethods)

- (void)_startCustomTransition;

@end

Now, you can override the method without problems:

class MyNavigationController: UINavigationController {
    override func _startCustomTransition() {
        super._startCustomTransition()
    }
}

EDIT: You have to declare the method in an Objective-C extension, because I see no way to declare a method in a Swift extension without implementing it. Suggestions are very welcome. :)

Tags:

Swift