• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSURLConnection problem on Mac OS X 10.7
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Fwd: NSURLConnection problem on Mac OS X 10.7 (From: Payal Mundhada <email@hidden>)
 >Re: NSURLConnection problem on Mac OS X 10.7 (From: Mike Abdullah <email@hidden>)
 >Re: NSURLConnection problem on Mac OS X 10.7 (From: Mike Abdullah <email@hidden>)

  • Prev by Date: Re: Custom universal types, but outside an application
  • Next by Date: Re: JSON Parser
  • Previous by thread: Re: NSURLConnection problem on Mac OS X 10.7
  • Next by thread: How to write song tags with iTunes and Scripting Bridge
  • Index(es):
    • Date
    • Thread