On Mar 15, 2010, at 4:32 PM, Rick Mann wrote: > Instead of passing my operation a target and selector, is there any way I can > just pass it a block, but then have it execute that block on the main thread?
Note that the methods listed so far will cause a deadlock if called from the main thread. For the non-parameters form I use the below as a category on NSObject, should be trivial to add arguments. Gerd - (void)runOnMainQueue:(void (^)(void))aBlock { // // Execute *aBlock* on the main queue/thread. // // # Parameters // aBlock // : The block to be executed. // // # Discussion // When called from the main queue the block is executed immediately. // Otherwise the block will be scheduled for execution on the main queue, // the method will return after the block was executed. // if(dispatch_get_current_queue()==dispatch_get_main_queue()) { aBlock(); } else { dispatch_sync(dispatch_get_main_queue(),aBlock); } } _______________________________________________ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com