When passing a delegate to the a NSUrlConnection object like so:
[[NSURLConnection alloc] initWithRequest:request delegate:handler];
the object handler is used to implement connectionDidFinishLoading didReceiveData etc. I make a lot of calls to a number of web services and instead of creating one object for each, I have a central class for all that stuff:
@interface DataService : NSObject {}
- (void) search:(NSString *) name byAddress:(NSString *)address;
@end
so the implementation of that method creates the delegate to pass:
SearchDelegate *delegate = [[SearchDelegate alloc] init];
[self sendRequestToUrl:urlString withJson:jsonString andHandler:delegate];
what I am seeing in Instruments is that there is a memory leak on the SearchDelegate... so I think it is actually being retain'ed.
Tinkering a bit I changed my sendRequestToUrlMethod to have this:
// http code setup blah...
[[NSURLConnection alloc] initWithRequest:request delegate:handler];
[handler release];
and this seems to have gotten ridden of memory leak being reported in Instruments.