为了记录控制器之间的导航,我使用了 -popViewControllersAnimated: 方法的 swizzling。有时它会导致 EXC_BAD_ACCESS 出现奇怪的崩溃。可能是什么原因?
- (void)sw_popViewControllerAnimated:(BOOL)animated {
//1. get top controller before pop
//2. pop
//3. get top controller after pop
//4. log it
NSString *controllerFromIdentifier = @"";
__block NSString *controllerToIdentifier = @"";
NSDictionary *controllerFromAdditionalParams = @{};
UIViewController *topController = ((UINavigationController*)self).topViewController;
[self sw_popViewControllerAnimated:animated];
UIViewController *topControllerAfterPop = ((UINavigationController*)self).topViewController;
}