Subject: Re: My runloop-based async code breaks with GCD 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. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@xxxxxxxxxxxxxxx) 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/maillists%40codeha.us This email sent to maillists@xxxxxxxxx |