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 7445281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:47:10+00:00 2026-05-29T11:47:10+00:00

UPDATE: I made a mistake in my debugging – this question is not relavent

  • 0

UPDATE: I made a mistake in my debugging – this question is not relavent – please see comment below.

Note: I am using Automated Reference Counting

When my app starts – I present a view controller inside a UINavigationController with presentViewController:animated:completion. That view controller loads a second view controller on to the navigation stack. The second view controller uses [self.presentingViewController dismissViewControllerAnimated:YES completion:nil] to dismiss itself. My issue, is that neither dealloc nor viewDidUnload are ever called in the first view controller. However, with instruments, I can see that the view controller is no longer allocated once the presented view controllers are dismissed. The code that presents the first view controller is

- (void)viewDidAppear:(BOOL)animated                                                                                                                                                                                                         
{                                                                                                                                                                                                                                            
    [super viewDidAppear:animated];                                                                                                                                                                                                          

    //  check if our context has any accounts                                                                                                                                                                                                
    if( [self.accounts count] == 0 )                                                                                                                                                                                    
    {                                                                                                                                                                                                                                        
        //  Display the Add Account View Controller                                                                                                                                                                                          
        MySettingsViewController *settingsVC = [[MySettingsViewController alloc] initWithNibName:@"MySettingsViewController" bundle:nil];                                                                                                 
        settingsVC.appContext = self.appContext;                                                                                                                                                                                             

        UINavigationController *navVC = [[UINavigationController alloc] initWithRootViewController:settingsVC];                                                                                                                              
        navVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;                                                                                                                                                                    

        if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)                                                                                                                                                      
        {                                                                                                                                                                                                                                    
            //  Display the Add Account View Controller                                                                                                                                                                                      
        }                                                                                                                                                                                                                                    
        else                                                                                                                                                                                                                                 
        {                                                                                                                                                                                                                                    
            navVC.modalPresentationStyle = UIModalPresentationFormSheet;                                                                                                                                                                     
        }                                                                                                                                                                                                                                    

       [self presentViewController:navVC animated:YES completion:nil];                                                                                                                                                                       
    }                                                                                                                                                                                                                                        
}            

So, I do not have any references to settingsVC that should be sticking around but I do not know why my dealloc is not being called. Any help would be great.

  • 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-05-29T11:47:11+00:00Added an answer on May 29, 2026 at 11:47 am

    They don’t get called because you haven’t correctly released your view controller.

    You allocate both settingsVC and navVC with alloc and thus get owning references to both that you must later release which you didn’t do.

    You can do it like this:

    - (void)viewDidAppear:(BOOL)animated                                                                                                                                                                                                         
    {                                                                                                                                                                                                                                            
        [super viewDidAppear:animated];                                                                                                                                                                                                          
    
        //  check if our context has any accounts                                                                                                                                                                                                
        if( [self.accounts count] == 0 )                                                                                                                                                                                    
        {                                                                                                                                                                                                                                        
            //  Display the Add Account View Controller                                                                                                                                                                                          
            MySettingsViewController *settingsVC = [[MySettingsViewController alloc] initWithNibName:@"MySettingsViewController" bundle:nil];                                                                                                 
            settingsVC.appContext = self.appContext;                                                                                                                                                                                             
    
            UINavigationController *navVC = [[UINavigationController alloc] initWithRootViewController:settingsVC];
            navVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;                                                                                                                                                                    
    
            // At this points, "settingsVC" is additionally retained by the navigation controller,
            // so we can release it now.
            [settingsVC release];
    
            if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)                                                                                                                                                      
            {                                                                                                                                                                                                                                    
                //  Display the Add Account View Controller                                                                                                                                                                                      
            }                                                                                                                                                                                                                                    
            else                                                                                                                                                                                                                                 
            {                                                                                                                                                                                                                                    
                navVC.modalPresentationStyle = UIModalPresentationFormSheet;                                                                                                                                                                     
            }                                                                                                                                                                                                                                    
    
            [self presentViewController:navVC animated:YES completion:nil];
    
            // At this point "navVC" is retained by UIKit, so we can release it as well.
            [navVC release];
        }                                                                                                                                                                                                                                        
    }           
    

    An alternative would have been to autorelease both right away.

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

Sidebar

Related Questions

By mistake I ran the update query. This update made my table all rows
I made what I now see as a mistake (better now than later, not
-edit- nevermind, i made a mistake in my select statement. Update was working correctly.
As made clear in update 3 on this answer , this notation: var hash
Update: Solved, with code I got it working, see my answer below for the
Update: Check out this follow-up question: Gem Update on Windows - is it broken?
UPDATE: Focus your answers on hardware solutions please. What hardware/tools/add-in are you using to
I released an update to one of my apps recently. This update made some
I have an existing app in which I made the mistake of using String.GetHashCode
** MAJOR UPDATE ** I made a minor mistake but I'm still curious about

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.