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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:34:14+00:00 2026-05-19T22:34:14+00:00

Apple guide is very specific about releasing connection object: it’s done in didFailWithError and

  • 0

Apple guide is very specific about releasing connection object: it’s done in didFailWithError and connectionDidFinishLoading.

Yet, when I do the same, I later get this in zombi-mode

*** -[NSURLConnection releaseDelegate]: message sent to deallocated instance 0x1001045b0

It seems, there’s some code in AppKit which releases connection for me.

I’d be happy to assume that Apple guide is wrong, but do not want to get some terrible memory leak or introduce some subtle incompatibility with older OSX versions or something like that.

Is it safe to ignore documentation in this case?

edit
Code creating request

  URLConnectionDelegate *delegate = [[URLConnectionDelegate alloc] initWithSuccessHandler:^(NSData *response) {
      ...
  }];
  [NSURLConnection connectionWithRequest:request delegate:delegate];  

  // I do not release delegate when testing for this issue, not sure whether I should in general

Delegate class itself

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
  successHandler(receivedData);

  [receivedData release];
  Block_release(successHandler);

  // do we really need this????????
  [connection release];
}
  • 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-19T22:34:15+00:00Added an answer on May 19, 2026 at 10:34 pm

    Since you’ve created your connection with

    [NSURLConnection connectionWithRequest:request delegate:delegate]; 
    

    you don’t own that connection object, hence you shouldn’t release it.

    That being said, I wouldn’t recommend it. If you don’t own an object, you have no guarantee that it will outlive autorelease pool drain cycles, i.e., it could be the case that your connection object is (auto)released before it’s finished loading. Instead, create a retain declared property to hold the connection:

    @property (retain) NSURLConnection *connection;
    

    assign your connection object to the declared property:

    self.connection = [NSURLConnection connectionWithRequest:request
        delegate:delegate]; 
    

    and, when the connection finishes loading or fails, release it by assigning nil to the declared property:

    self.connection = nil;
    

    As for your delegate, if it only needs to exist whilst the connection is loading, you can autorelease it since the connection retains the delegate:

    URLConnectionDelegate *delegate = [[[URLConnectionDelegate alloc]
        initWithSuccessHandler:^(NSData *response) {
        // …
    }] autorelease];
    
    self.connection = [NSURLConnection connectionWithRequest:request
        delegate:delegate]; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While most apple documents are very well written, I think ' Event Handling Guide
I have read the Apple documentation. They list the apps registered, yet in their
I saw the Apple keynote address and was very impressed by the new Places
The Apple UI design guide suggests that a UIPageControl is ideal for presenting the
I have a custom framework that, following the advice in Apple's Framework Programming Guide
Apple's Threading Programming Guide states that: Although good for occasional communication between threads, you
I read the guide http://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html and tried http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStoreServices.woa/wa/itmsSearch?limit=100&term=finance&output=json&media=all&entity=software&country=us it returns nothing, why ?
I'm customizing a tableviewcell which is still very hard to me. After reading apple's
I have seen the in-app purchrasing programming guide for apple. But it is mandatory
Apple strongly recommends using the binary plist format when reading large XML-based data sets

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.