iOS9 对 UINavigationController 实例的弱引用

iOS 9 Weak Reference to Instance of UINavigationController

我正在维护一个应用程序。 XCode 7.3 和 iOS 9.3 给我一个我以前从未见过的错误:

"Cannot form weak reference to instance (0x15243a00) of class UINavigationController. It is possible that this object was over-released, or is in the process of deallocation."

我的 AppDelegate 中有问题的代码如下:

#pragma mark - Setup Storyboard and Side Menu

- (UINavigationController *)navigationController {

UIStoryboard*  sb = [[UIStoryboard alloc]init];

if (IS_IPAD) {
    sb = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad" bundle:nil];
}
else {
    sb = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
}

UIViewController* vc = [sb instantiateViewControllerWithIdentifier:@"principalView"];

return [[UINavigationController alloc] initWithRootViewController:vc];
}

- (MFSideMenu *)sideMenu {

SideMenuViewController *sideMenuController = [[SideMenuViewController alloc] init];
UINavigationController *navigationController = [self navigationController];

MFSideMenuOptions options = MFSideMenuOptionMenuButtonEnabled|MFSideMenuOptionBackButtonEnabled
|MFSideMenuOptionShadowEnabled;
//MFSideMenuOptions options = MFSideMenuOptionMenuButtonEnabled|MFSideMenuOptionShadowEnabled;
MFSideMenuPanMode panMode = MFSideMenuPanModeNavigationBar|MFSideMenuPanModeNavigationController;

MFSideMenu *sideMenu = [MFSideMenu menuWithNavigationController:navigationController
                                             sideMenuController:sideMenuController
                                                       location:MFSideMenuLocationLeft
                                                        options:options
                                                        panMode:panMode];

sideMenuController.sideMenu = sideMenu;

return sideMenu;
}

- (void) setupNavigationControllerApp {

self.window.rootViewController = [self sideMenu].navigationController; //HERE IS WHERE I AM DETECTING THE APP CRASHING
[self.window makeKeyAndVisible];
}

实例的强引用在哪里设置?

在摆弄我的 UINavigationController 对象一段时间后,我想到了这个解决方案:

- (void) setupNavigationControllerApp {

__strong UINavigationController *test = [self sideMenu].navigationController;

self.window.rootViewController = test;
[self.window makeKeyAndVisible];
}