• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Crash from NSURLConnection if delegate released too soon?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Crash from NSURLConnection if delegate released too soon?


  • Subject: Re: Crash from NSURLConnection if delegate released too soon?
  • From: Jens Alfke <email@hidden>
  • Date: Mon, 25 Aug 2014 09:54:07 -0700

> On Aug 25, 2014, at 9:40 AM, Howard Moon <email@hidden> wrote:
>
> Ok, I fixed it. I was using the connection object as a member of my class, and releasing that, when I should have been releasing the connection that is given to me inside didFailWithError and connectionDidFinishLoading, not making it a member at all.

It should be OK either way as long as you're following the ref-counting rules (or are using ARC.)
* Only release the NSURLConnection if you allocated it by calling +alloc
* Don't release the NSURLConnection instance passed into your delegate methods

Also, NSURLConnection instances always stay alive until the connection finishes (they are retained by CFNetwork internally) so you actually don't need to retain them yourself.

—Jens
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Crash from NSURLConnection if delegate released too soon?
      • From: Howard Moon <email@hidden>
References: 
 >Crash from NSURLConnection if delegate released too soon? (From: Howard Moon <email@hidden>)
 >Re: Crash from NSURLConnection if delegate released too soon? (From: Howard Moon <email@hidden>)
 >Re: Crash from NSURLConnection if delegate released too soon? (From: Howard Moon <email@hidden>)

  • Prev by Date: Re: Crash from NSURLConnection if delegate released too soon?
  • Next by Date: WebView shorting me on print jobs.
  • Previous by thread: Re: Crash from NSURLConnection if delegate released too soon?
  • Next by thread: Re: Crash from NSURLConnection if delegate released too soon?
  • Index(es):
    • Date
    • Thread