Saving rootViewController?

I wonder if anyone can help me regarding memory management in the code below. I'm particularly interested in rootController, it persists when I execute initWithRootViewController or instead (this is my hunch), it is saved in the addSubView window: I'm just wondering what happens ...

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    Base_TableViewController *rootController = [[Base_TableViewController alloc] init];
    navController = [[UINavigationController alloc] initWithRootViewController:rootController];
    [window addSubview:[navController view]];
    [window makeKeyAndVisible];

    [rootController release];
    return YES;
}

- (void)dealloc {
    [navController release];
    [window release];
    [super dealloc];
}

EDIT:

So, essentially, the code above is correct, the release at the bottom cancels the selection at the top, does the "rootController" persist navController?

Thank you very much, very grateful.

Gary

+3
source share
2 answers

alloc init count rootController . navController initWithRootViewController, ( , UINavigationController ).

navController rootController ( UIView navController).

rootController .

Edit

. , .

+3

initWithRootViewController: rootController. addSubview: navController.view

EDIT: . [rootController release] rootController, , initWithRootViewController.

+3

Source: https://habr.com/ru/post/1761493/


All Articles