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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:34:40+00:00 2026-05-18T09:34:40+00:00

I have a controller class that uses asynchronous calls to perform some network operations.

  • 0

I have a controller class that uses asynchronous calls to perform some network operations. My view hierarchy is navigation based e.g. View1 > View2 > View3.

Now lets suppose my View3 (View3Controller) uses asynchronous calls to perform some network operations, and View2Controller also implements some of the delegate methods as well.

User can use “Back” button to navigate back at anytime, and consequently [View3Controller dealloc] gets called. Now i want the async operation to complete! Is there a (safe) way to make sure that View3Controller doesn’t get dealloc‘ed until the async operation is completed?

  • 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-18T09:34:41+00:00Added an answer on May 18, 2026 at 9:34 am

    One solution is to move the asynchronous call to its own class, preferably owned by View2Controller or someone higher up. When pushing View3Controller you just pass along this new class and if the user navigates back it will continue as you want.

    Imagine an object like:

    AsyncObject : NSObject {}
    @property (nonatomic, assign) id delegate;
    - (void)start;
    

    and when pushing View3Controller

    View3Controller *view3Controller = ...
    view3Controller.asyncObject = self.asyncObject;
    [self.navigationController pushView....];
    

    and when starting the async operation from within View3Controller

    self.asyncObject.delegate = self;
    [self.asyncObject start]; 
    

    if the user navigates back you could potentially do something like this in navigationController:willShowViewController:animated: in View2Controller do get the callbacks from asyncObject in case View3Controller gets popped.

    - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
      if (viewController == self) {
        self.asyncObject.delegate = self;
      }
    }
    

    If you need to be able to receive events from the asyncObject for several objects at the same time you should look at notifications or KVO (Key Value Observing) instead of using a delegate.

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

Sidebar

Related Questions

I have a TableView controller class that uses a fetched results controller to display
I am using MVC 2. I have a BaseController class that every Controller uses.
I have an MVC view page that uses a master page. The master page
I have an app that uses Devise and CanCan. in the config>initializers>Abiliity.rb class Ability
I have an Apex class (controller) originally developed under Developer Edition and need to
I have a controller with an action method as follows: public class InventoryController :
I have an action like this: public class News : System.Web.Mvc.Controller { public ActionResult
When submitting one form from view, how can i also read or have controller
I have a controller action that is being executed by a link that was
I have multiple controller actions that takes an id public ActionResult Get(int? id) {

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.