Method swizzling + iOS9 = crash

WARNING! This bug is reproduced on very random devices with iOS9.


@implementation UINavigationController (Extension)
- (void)presentViewControllerSwizzle2:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion
{
    [ self presentViewControllerSwizzle2:viewControllerToPresent animated:flag completion:completion ];
}
#pragma mark -
+ (void)swizzle:(Class)class oldSelector:(SEL)old newSelector:(SEL)new
{
    Method oldMethod = class_getInstanceMethod(class, old);
    Method newMethod = class_getInstanceMethod(class, new);


    if(class_addMethod(class, old, method_getImplementation(newMethod), method_getTypeEncoding(newMethod)))
    {
        class_replaceMethod(class, new, method_getImplementation(oldMethod), method_getTypeEncoding(oldMethod));
    }
    else
    {
        method_exchangeImplementations(oldMethod, newMethod);
    }
}
+ (void)load
{
    [self swizzle:UINavigationController.class oldSelector:@selector(presentViewController:animated:completion:) newSelector:@selector(presentViewControllerSwizzle2:animated:completion:)];
}
@end


And somewhere on button click:

UIViewController *vc = [[UIViewController alloc] init];
[self.navigationController presentViewController:vc animated:YES completion:nil];


I just added this code into the default example "Master-Detail application"

Method swizzling + iOS9 = crash
 
 
Q