'how to set rootViewController of UINavigationController programmatically (objective C)

**Here is my code snippet. I Just want to change rootView before instantiating the View. Currently how it work is Login>Main>and so on. Just want to remove the first one(login) from Navcontroller. Thanks in advance **

- (void)presentMainControllerForRefreshSesion {
LoginViewController * __weak weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^{
    UINavigationController *rootNavController = (UINavigationController *)UIApplication.sharedApplication.delegate.window.rootViewController;
    if (![rootNavController.childViewControllers containsObject:weakSelf.mainController]) {
        weakSelf.mainController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"mainController"];
        [rootNavController pushViewController:weakSelf.mainController animated:YES];
        [rootNavController setNavigationBarHidden:false];
    }
});

}



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source