Re: NSURLConnection problem on Mac OS X 10.7
Re: NSURLConnection problem on Mac OS X 10.7
- Subject: Re: NSURLConnection problem on Mac OS X 10.7
- From: Jens Alfke <email@hidden>
- Date: Thu, 08 Sep 2011 20:15:46 -0700
On Sep 8, 2011, at 2:46 AM, Mike Abdullah wrote:
>> In delegate connectionDidFinishLoading handling as follows:
>> -(void)connectionDidFinishLoading:(NSURLConnection *)connection
>> {
>> @try {
>> CFRunLoopStop(m_runLoopRef);
>> [m_connection release];
>> m_connection =nil;
>> }
>> }
Ow. Don’t do this. Stopping the runloop is not the right thing to do. If you really want to see how to block till an NSURLConnection finishes, one example is this code of mine:
https://github.com/couchbaselabs/CouchCocoa/blob/master/REST/RESTOperation.m
Really though, it’s better to write your code to be asynchronous. Writing synchronous code and then making it run on a background thread because it blocks the UI, is effectively the same result as writing it asynchronously, just more complicated and error-prone.
—Jens_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden