entropid
entropid

Reputation: 6239

Cancelling NSURLConnection when leaving a view

Do I need to cancel the opened connections (NSURLConnection) when I leave the view? I'd do that in viewWillDisappear or viewDidDisappear but I don't know whether I actually need to do that.

Upvotes: 0

Views: 103

Answers (1)

Michael Dautermann
Michael Dautermann

Reputation: 89509

If you're using ARC, there's a good chance your NSURLConnection objects (assuming they are instance variables or that you're holding onto them in memory somehow) will get magically released when the view controller goes away.

But to be sure, and to be nice, you should cancel the open connections. Doing the NSURLConnection object "cancel" in either "viewWillDisappear" or "viewDidDisappear" should work well.

Upvotes: 1

Related Questions