On Sat, 18 Feb 2012 01:24:00 -0500, Dave Keck <davek...@gmail.com> said: >The root of your problem seems to be your assumption that GCD runs the run >loop. > >NSURLConnection case: the delegate methods aren't called because >NSURLConnection machinery requires the run loop to be run, which GCD >isn't going to do for you. (Calling -setDelegateQueue: fixes this >because NSURLConnection presumably has a secondary operating manner >that uses an NSOperationQueue instead of a run loop). > >Perform selector case: likewise, this doesn't work when called from a >queue because GCD isn't going to handle running the run loop for you. > >The run loop is run by something calling CFRunLoopRunInMode(). On the >main thread, this is typically handled for you by AppKit (specifically >by NSApplication's -nextEventMatchingMask:). On secondary threads, you >must manually invoke CFRunLoopRunInMode() to allow anything relying on >the run loop to work correctly. (NSURLConnection uses run loop sources >to work in the non-NSOperationQueue case, and -performSelector uses a >timer.) > >In short, dispatch queues are a lower-level abstraction to the run >loop, and won't run the run loop for you.
What made this light bulb come on for me was watching the video of Quinn's incredibly great lecture from WWDC 2010; in particular, see Session 208. Wow. See also his MVCNetworking example, which demonstrates the architecture he constructs during that talk. m. -- matt neuburg, phd = m...@tidbits.com, <http://www.apeth.net/matt/> A fool + a tool + an autorelease pool = cool! Programming iOS 5! http://shop.oreilly.com/product/0636920023562.do _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com