Reputation: 130
I am performing maintenance to an app. XCode 7.3 with iOS 9.3 is giving me an error that I have never seen before:
"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."
The offending code in my AppDelegate is the following:
#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];
}
Where can I set up the strong reference to the instance?
Upvotes: 0
Views: 830
Reputation: 130
After fiddling with my UINavigationController object for a while, I came up with this solution:
- (void) setupNavigationControllerApp {
__strong UINavigationController *test = [self sideMenu].navigationController;
self.window.rootViewController = test;
[self.window makeKeyAndVisible];
}
Upvotes: 0