Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to release NSUrlConnection object

Tags:

iphone

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?

like image 223
Alan Avatar asked Oct 11 '09 18:10

Alan


1 Answers

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.

like image 117
G Gordon Worley III Avatar answered Oct 05 '22 02:10

G Gordon Worley III