Is there a way to implement NSURLConnection without it leaking? A number of Apps including NYTimes and others (including mine) suffer from this. Anyone have a working implementation?
views:
2064answers:
2
+1
A:
According to the documentation, +[NSURLConnection sendSynchronousRequest:returningResponse:error:]
is built on top of the asynchronous loading code made available by NSURLConnection
. It would not be difficult to reimplement this by spawning and blocking on an NSThread
, running the request asynchronously in the background on a run loop and ending the thread once either connectionDidFinishLoading:
or connection:didFailWithError:
is received.
Of course, you are better off using the asynchronous code in the first place; it makes for a much better user experience
rpetrich
2009-08-25 19:51:01
calling sendSynchronousRequest asynchronously is a lot simpler than implementing the asynchronous request yourself.
me
2009-10-16 21:00:09
+2
A:
It appears that best practice is to use NSURLConnection asynchronously.
Jordan
2009-09-06 00:24:54