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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:55:28+00:00 2026-05-25T10:55:28+00:00

I have a view controller myViewController that makes HTTP requests. I set the request’s

  • 0

I have a view controller “myViewController” that makes HTTP requests. I set the request’s delegates to self (the instance of myViewController). Everything works fine until I pop myViewController off the navigation stack before a request returns. In this case the request tries to send a message to the dealloc’d myViewController (which causes my app to crash).

Currently I’m patching/solving this problem by setting the delegate of all requests to nil in myViewController’s dealloc method. What’s a better way to do this?

Perhaps a singleton could be responsible for handling all HTTP requests?

  • 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-25T10:55:29+00:00Added an answer on May 25, 2026 at 10:55 am

    A while ago I had this same problem for UIWebView delegate events. The solution is to keep track of all outgoing HTTP requests within your myViewController. So, keep an instance variable called mutableRequests onto which you add every request that you send. It will probably also be a good idea to remove requests from this array once they are finished.

    In the -viewWillUnload method, simply enumerate through mutableRequests and cancel every request. This will not only allow you to cancel all requests before your view is deallocated, but it will also help you respect the release/retain programming model by retaining all of the objects in an array while they are in use.

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

Sidebar

Related Questions

Lets say I have a view, myView, a view controller, myViewController, and some sort
I have a view controller class that has to implement several protocols. Too keep
I have a view controller that gets presented modally and changes some data that
I have a view called MyViewController, that I initialize from a xib file. Its
I have a custom view controller that I push onto my navigation stack as
I have a custom view controller that implements the from UITableViewDataSource and UITableViewDelegate protocols.
I have a view controller that is used to populate data from the core
This has me scratching my head. I have a view controller that implements UIPopoverControllerDelegate
I have a document-based application with a view controller that contains a table, array
I have a navigation controller and in it a view controller: -NavigationController1 --MyViewController And

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.