Summary of my question: Does NSURLConnection retain its delegate?
Detailed question and scenario:
I have a custom class, called JsonDownloader that is takes in a URL and returns an NSDictionary of the JSON that the URL returns.
On an iPhone app, I do something like this. (the init method kicks off the whole process)
- (void)viewDidLoad { JsonDownloder *temp = [[[JsonDownloader alloc] initWithURL:urlString returnDataTo:self]]; [temp release]; [super viewDidLoad]; }
When the JsonDownloader is done downloading and parsing, it performs a callback to the returnDataTo: object, in this case, the calling object.
This works just fine. Even if I introduce a 30 second delay in my web servers response, the JsonDownloader still exists and does it's callback correctly.
So my questions is this: What is keeping JsonDownloader way past the end of the event cycle? I am explicitly releasing it.
My hunch is that NSURLConnection must do a retain on its delegate, but I didn't see anything in the documentation. Anyone have an ideas?