multithreading - NSURLConnection in background Thread -
i want load (big) asynchronously in background thread (use nsoperation).
after many searches came across 2 options: first use with:
cfrunlooprun()
which explain wonderful in link : http://www.russellj.co.uk/blog/2011/07/09/nsurlconnection-in-a-background-thread/
the second use with:
nsport* port = [nsport port]; nsrunloop* rl = [nsrunloop currentrunloop]; // runloop rl addport:port formode:nsdefaultrunloopmode];
which explain in link : http://www.cocoaintheshell.com/2011/04/nsurlconnection-synchronous-asynchronous/
i realy want use first option because elegant , readability. i'm afraid not understand differences between 2 approaches.
thanks help.
i'd recommend following built-in method if suits needs. it's easy use , reliable.
- (void)sendasynchronousrequest:(nsurlrequest *)request queue:(nsoperationqueue )queue completionhandler:(void (^)(nsurlresponse, nsdata*, nserror*))handler
Comments
Post a Comment