What is the correct point at which to release a NSUrlConnection object?
In my program, I alloc a NSUrlConnection, and then initWithRequest to kick off asynchronously.
I am now responsible for releasing the object - when do I/can I release? Immediately if I'm not using it again?
When you are done with the NSURLConnection
. You'll know you're done with it when your NSURLConnection
delegate receives - (void)connectionDidFinishLoading:(NSURLConnection *)connection
or - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
. Just release it at the end of those two methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With