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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:31:37+00:00 2026-05-15T08:31:37+00:00

The code for this question is too long to be of any use. But

  • 0

The code for this question is too long to be of any use. But I’m pretty sure my problem has to do with releasing a class.

I have a helper class, ConnectionHelper.h/.m, that handles a NSURLConnection for me. Basically, I give it the URL I want and it returns the data (it happens to do a quick json parse on it too). It has a delegate which I set to the calling class (in this case: DownloadViewController). When it finishes the download, it calls [delegate didFinishParseOf:objectName withDictionary:dictionary];. Then in DownloadViewController I release ConnectionHelper and alloc a new one in order to download the next object.

My problem is, I do this once, and then it creates the connection for the second one, and then my program just crashes. After this call:

[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyNever];  
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];

Then I don’t think any of the following methods are called:

- (NSCachedURLResponse *)connection:(NSURLConnection *)connection 
              willCacheResponse:(NSCachedURLResponse *)cachedResponse

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error

- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge

So am I right in that I’m not releasing something? When I release it the first time, the dealloc function isn’t being called. Is there a way I can “force” it to deallocate? Do I need to force it to? I didn’t think it would matter since I allocating a new ConnectionHelper for the new call. How else would they overlap / conflict with each other?

Thank you.

  • 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-15T08:31:37+00:00Added an answer on May 15, 2026 at 8:31 am

    First of all you never force deallocate. If you follow the memory management rules closely then you shouldn’t even have to worry about it. For the rules Look at:

    http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/MemoryMgmt/Articles/mmPractical.html#//apple_ref/doc/uid/TP40004447-SW1

    If your app is crashing it sounds to me more like something is being released early. Probably the object which you are setting as the delegate for your connection. Last but not least have you looked at ASIHTTPRequest for handling connections? It’s a CFNetwork wrapper, very simple to use and very powerful.

    Hopes this helps.

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

Sidebar

Related Questions

I was checking out this question which has this code - (NSArray *) percentagesRGBArray:(float[])
I am using the BlockingQueue code posted in this question , but realized I
In answering this code golf question , I ran across a problem in my
I hope this question will not be rejected as there is no code. But
Today I came across this question: you have a code static int counter =
This is a follow-up question to a different question I asked not too long
I asked this kind of question before, but didn't receive any good answers, perhaps
Disclaimer: I have looked through this question and this question but they both got
Is there any replacement for z-index? My code is too long, thus I will
in this question I posted you can see the originating code sample for this

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.