NSURLConnection and Xcode Assembly and Analysis

I follow the documentation for using NSURLConnection and use delegates to control the connection (overriding, among other methods, the connection: didFailWithError: and connectionDidFinishLoading: . The memory allocated for the NSURLConnection object is allocated in these delegate methods.

My problem is that running "Build / Build and Analyze" from the Xcode menu causes the annoying "Potential Object Leak (...)" warning in the method that calls alloc in the NSURLConnection class (logically enough, as I don't release it in that same block).

Can I turn off this warning?

+1
objective-c iphone xcode
source share
3 answers

A way to bypass this storage object in a stored instance variable. Then you can safely release it at the end of your first method.

0
source share

When you click on the message Analyzer, you get additional information showing the execution path, etc. Does this mean it's just stupid, or does it give you a clue about what might be wrong?

Assuming the parser is just dumb, I would just save the link in ivar if the message bothers you, and then release it from -dealloc.

Releasing the allocated resource from the delegate method seems to me a little voodoo anyway. I will even be tempted to move all the code that processes NSURLConnection to its class.

0
source share

I am with Florent. The "Listing 1" in the Apple documentation in the NSURLConnection marks the "potential leak" in the "assembly and analysis". However, when the [theConnection release] method is run at the end of the method, it crashes.

I would like someone to comment on this for me!

0
source share

All Articles