Is it OK to retain a delegate of a subclass of ASIHTTPRequest?
I made a subclass of ASIHTTPRequest called JSONRequest. Each instan
What's retaining the request? (The operation queue, perhaps? Who knows?)
In general, the "fire-and-forget-and-give-me-a-callback" method you seem to be proposing is a bad idea. If nothing is retaining the VC apart from the request, then (unless your app structure is a bit silly) the VC will never get to do anything with the data it receives, so there's no reason for it to continue.
It also feels wrong: Does the request own the VC, or does the VC own the request? I'd expect the latter, so the VC should also retain the request.
There are a couple of exceptions:
For these cases, I often work around it with a "weak proxy" class which doesn't retain its target (and I wrote a "weak timer" wrappers around NSTimer/CADisplayLink to make this a bit easier.)
What you're supposed to do is keep track of the requests that you've initiated and in dealloc, do something like
request.delegate = nil;
[request cancel];
self.request = nil;
Similarly, you're supposed to unregister for notifications/actions/KVO callbacks at the appropriate time. There's an exception:
There are exceptions to the exception: