Re: NSURLConnection retains its delegate
Re: NSURLConnection retains its delegate
- Subject: Re: NSURLConnection retains its delegate
- From: Scott Anguish <email@hidden>
- Date: Thu, 10 Aug 2006 15:53:46 -0700
I wasn't aware that this was the case.. it does happen rarely though.
some research indicates that yes, it does retain it, but that it is
released when the collection has finished loading, fails, or is
cancelled.
the doc should state this though. I've filed a bug and will fix this
On Aug 10, 2006, at 9:30 AM, Jonathan del Strother wrote:
I ran into an odd problem recently where my objects that I created
to receive a response from an NSURLConnection were never getting
released. After several hours of debugging, I finally discovered
that NSURLConnection seems to retain its delegate.
BBConnectionHandler* connectionHandler = [[BBConnectionHandler
alloc] init]; //connectionHandler has a retain count of 1
NSURLConnection* connection = [NSURLConnection
connectionWithRequest:request delegate:connectionHandler];
//connectionHandler now has a retain count of 2.
...which all lead to a rather unpleasant retain cycle that was a
pain in the ass to unwind.
Surely this is wrong? I'm sure I remember reading somewhere that
objects should not retain their delegates for exactly the above
reason. This isn't standard behavior - shouldn't it at least be
documented?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden