//
//  UINavigationController+CompletionBlock.m
//  OneCable
//
//  Created by ncomz on 2017. 6. 28..
//  Copyright © 2017년 ntels. All rights reserved.
//

#import "UINavigationController+CompletionBlock.h"

@implementation UINavigationController (CompletionBlock)

- (UIViewController *)popViewControllerAnimated:(BOOL)animated completion:(void (^)()) completion {
    [CATransaction begin];
    [CATransaction setCompletionBlock:^{
        completion();
    }];
    
    UIViewController *vc = [self popViewControllerAnimated:animated];
    
    [CATransaction commit];
    
    return vc;
}
- (NSArray< UIViewController *> *)popToRootViewControllerAnimated:(BOOL)animated completion:(void (^)()) completion {
    [CATransaction begin];
    [CATransaction setCompletionBlock:^{
        completion();
    }];
    
    NSArray< UIViewController *> *vcs = [self popToRootViewControllerAnimated:animated];
    
    [CATransaction commit];
    
    return vcs;
}

@end
