views:

117

answers:

1

I have been following the documentation for using NSURLConnection and am using delegates for managing the connection (overriding among other methods connection:didFailWithError: and connectionDidFinishLoading:). The memory allocated for the NSURLConnection object is released in those delegate methods.

My problem is that running "Build/Build and Analyze" from the XCode menu triggers an annoying "Potential leak of an object (...)" warning in the method calling alloc on the NSURLConnection class (logically enough as I do not release it in the same block).

Is there a way to silence this warning?

A: 

When you click on the Analyzer message it gives you more information, showing the path of execution etc. Does this indicate that it's just being dumb or does it give you a hint as to what might be wrong?

Assuming the analyzer is just being dumb, I'd just keep the reference in an ivar if the message bothers you, then release it from within -dealloc.

Releasing an allocated resource from within a delegate method feels a bit voodoo to me in any case. I'd even be tempted to move all of the code that's processing the NSURLConnection into its own class.

d11wtq
No it does not tell me anything more than what I already know: the release message is not sent in the method allocating the object, but in the delegate.This is caused by the fact that the connection is released in the delegate methods, as explained in the apple documentation I refer to.Keeping the reference in an ivar is probably a way to shut down the message, you´re right, but I would hope that there is another cleaner way to acheive my goal (correct memory management, no warnings).
Florent Legendre