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

  • Home
  • SEARCH
  • 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 6102071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:34:20+00:00 2026-05-23T13:34:20+00:00

I have a simple navigation hierarchy: Controller 1 > Controller 2 > Controller 3

  • 0

I have a simple navigation hierarchy:

Controller 1 > Controller 2 > Controller 3

Each controller contains a reference (@property (nonatomic, assign) ...) to it’s child and parent.

My viewWillDisappear looks something like this:

- (void)viewWillDisappear:(BOOL)animated {
    NSLog(@"%s", __FUNCTION__);

    if (![self.navigationController.viewControllers containsObject:self]) {
        // View has been popped! Important to distinguish between view popping and tab switching.
        // If parent view controller is active, pass a message.
        if (_refParentViewController && !_isSearchViewController) {
            _refParentViewController.valueX = @"xyz";
        }
    }

    [super viewWillDisappear:animated];
}

Now, there’s a case where following statement is executed (by Controller 1):

[self.navigationController popToRootViewControllerAnimated:NO];

As a result, i get a crash because _refParentViewController is a deallocated instance (at this point). How can i check whether _refParentViewController is valid? I thought that the view controllers/views will get destroyed in order but it appears that there isn’t any specific order and Controller 2 is destroyed before Controller 3.

I can check retainCount but i’m not sure if that’s a good idea.

  • 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-23T13:34:21+00:00Added an answer on May 23, 2026 at 1:34 pm

    I can check retainCount but i’m not
    sure if that’s a good idea.

    It is a horrible idea; retainCount is useless, don’t call it. And note that retainCount can never return 0; it can’t be used to know if an object is deallocated or not.

    If both your parent and child properties are assign, then who is responsible for retaining the view controller? You need a retain that spans the expected lifespan of the parent/child properties.

    I would suggest that you make the child property retain and leave the parent property as assign. You also need to make sure that when you set the child to nil (which, with a retain property will release it as long as you go through the property’s setter) that you first set the child’s parent property to nil.

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

Sidebar

Related Questions

I would like to have a view (Hierarchy structure) under Navigation Controller (the top
I have a root view controller with just a simple navigation button that loads
I have a navigation view with a cell that has something as simple as
I have a simple site consisting of a root site with 2 child sites.
I have a simple navigation based app which has a bunch fo forms in
Greetings! I have a simple navigation menu consisting of an asp:DropDownList and an asp:Button.
I have a simple navigation system in a sidebar on a page that you
My problem is as follows: I have a simple navigation <ul class=navigation> <li class=heading
I have a simple Tab Navigation with jquery. Whenever a new tab is clicked,
I have a simple black navigation bar with following button When the button is

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.