Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8367713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:13:45+00:00 2026-06-09T13:13:45+00:00

I am having around 9 ViewControllers in my application. I am opening the ViewControllers

  • 0

I am having around 9 ViewControllers in my application. I am opening the ViewControllers using the presentModalViewController. I want to display the 1st ViewController every time the user enters background and comes to foreground. If the user enters background in 8th ViewController and opens the application again , I need to display the 1st View Controller.

I am using the following code in the applicationWillEnterForeground

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    self.HomeScreenViewController = [[HomeScreenViewController alloc] initWithNibName:@"HomeScreenViewController" bundle:nil];
    self.window.rootViewController = _homeScreenViewController;
    [self.window makeKeyAndVisible];
}

and it is showing a memory leak. Obviously it will show the memory leak since I am initializing the HomeCtrl again, but I don’t know how to fix it. Can anyone help me ??
I am not using the UINavigationController since the ViewControllers are pushed from right or Left side.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:13:47+00:00Added an answer on June 9, 2026 at 1:13 pm

    Change:

    self.HomeScreenViewController = [[HomeScreenViewController alloc] ....];
    

    to

    _HomeScreenViewController = [[HomeScreenViewController alloc] ....];
    

    Or you can do something like follow code:

    HomeScreenViewController *tempHSVC = [[HomeScreenViewController alloc] ....];
    self.HomeScreenViewController = tempHSVC;
    [tempHSVC release];
    self.window.rootViewController = self.HomeScreenViewController //or use just _homeScreenViewController;
    [self.window makeKeyAndVisible];
    

    And read some articles about memory management in objc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way around having to restart tomcat every time a small change
I'm having trouble roating an image around itself using Canvas. Since you can't rotate
I am developing a project using Entity Framework 4. Having around 50 Entities, mostly
I have a student table, having around 5,000 records, in my DB. I want
I am developing an iPhone application in it I am having around 15 arrays
i'm having around 13 emulators .i want my app can adjustable in all emulators.
Is there any way around having to specify every sourcefile I create manually in
Having read around it appears this should be possible. I have the following content
I'm trying to use MVC for a new project after having been around the
I'm trying to decide the best way of having radiobuttons switch around the contents

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.