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

I have a UIView & I want that view's layer to be a continuously
I'm working on a view controller that can be presented modally or pushed into
I have a project that I created by using Xcode's Single View Application template.
I put an NSlog in my dealloc method of my view controller. It does
I use a .xib to layout my viewController and have 10 IBOutlet objects that
I have a UIViewController that has UISegmentedControl that displays 3 other views depending on
I have an app that uses the Status bar is initially hidden property in
I ran into something odd today that maybe someone knows something about. I have
I'm working on a project that just needs to be rewritten but that is
Just getting started on iPhone dev today and have run through Apple's HelloWorld tutorial:

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.