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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:06:46+00:00 2026-05-14T18:06:46+00:00

My view controller needs to know when it is popped out of the navigation

  • 0

My view controller needs to know when it is popped out of the navigation controller stack, so that it can retain itself, wait and release itself later with another notification.

I intend to do like that when the view is sent dealloc message:

- (void)dealloc {
    if (self.isPerformingSomeTask) {
        self.isPopedOut = YES;
        [self retain];
        return;
    }
    [super dealloc];
}

But I think this is not a good solution?

  • 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-14T18:06:47+00:00Added an answer on May 14, 2026 at 6:06 pm

    This is an extremely bad idea.

    1. “-dealloc” is not the place to retain the object that is deallocated. If you want to be absolutely sure, that your object is not deallocated, then retain it upon construction, e.g. in “-viewDidLoad”
    2. “-dealloc” is not a way to detect that a view is popped from the navigation stack. You could be deallocated for any reason or the deallocation could be delayed even though you were popped from the stack
    3. If you want to detect, that the view is not displayed anymore, you should look for “-viewWillDisappear:”
    4. The pope has nothing to do with it, so don’t pope out your views 🙂
    5. If you need some object to receive the results of a long running task, probably your AppDelegate is a better receiver, not the view controller

    EDIT: The following code refers to my comment below:

    So you code should look like this

    - (void) startMyLongTask {
      [self retain];
      // start the task
    }
    
    - (void) longRunningTaskReturns {
      // process results
      [self release];
    }
    
    - (void) dealloc {
      // as long as longRunningTaskReturns is not called
      // you will never come here
      [super dealloc];
    }  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to know when my view controller is about to get popped from
I realise that the view/controller stuff will be different between Mac and IPhone apps
My application is pretty simple: it starts up with a view controller that holds
In my view controller's -viewDidLoad method, I call [myTextField becomeFirstResponder]; This works like a
A simple question: I have a Model-View-Controller setup, with Models accessing a SQL database.
What are the alternative design methods to the Model View Controller? MVC seems to
Lets say I have a view, myView, a view controller, myViewController, and some sort
Short: how does modelbinding pass objects from view to controller? Long: First, based on
Should I use the same controller and view for editing and creating models in
How do you decide if something goes in the view or the controller? Here

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.