0
votes

I have a Login View where user enters username and password which is working fine to call the next view. Now when the user clicks logout, I am calling the Login viewController using following:

loginViewController *login = [[loginViewController alloc] initWithNibName:@"loginViewController" bundle:nil];
[self presentModalViewController:login animated:YES];

I don't know whether allocation the view again again on logout button action is a good idea. I am using ARC but I dont know calling the loginViewController will push all the allocated memory of previous viewControllers.

PS:

loginViewController is the root view controler -ie- it is called right after the appDelegate.

I have tried popViewController method of the navigationController but it is not working.

Any other suggestion would be really grateful

1
once logged in, later is a tabBar app..? - vishy
@vishy no its not a tab bar app. Once logged in, there is a button of user settings in which theres another button for logout. - madLokesh
Once successful login, u will be dismissing the loginViewController.. so no longer this will be in memory.. ARC will release it.. after logout, u r again allocating & presenting it, its fine.. works fine.. - vishy
ok...could you post as an answer so that i can accept it - madLokesh
i have added a answer with a sample template, for login/logout transitions.. - vishy

1 Answers

3
votes

As you are using ARC, the objects are managed by the iOS, so once you dismiss the loginViewController it will no longer available in memory. So you for next time you need to allocate & present the loginView again, your code is fine, works good..

I have a sample app made using tabBar with login & logout transitions. Here you can change your rootViewController as per your requirement.