Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Grand Central Dispatch anyone?

Grand Central Dispatch anyone?
Thread Tools
Mac Elite
Join Date: Sep 2006
Location: Punta Cana, República Dominicana
Status: Offline
Reply With Quote
Jun 10, 2010, 09:23 AM
 
I've been teaching myself Xcode / Cocoa / Objective-C programming for the last year or so. I finally decided to delve into GCD. I couldn't believe how frickin' easy it was to add multi-threading to my app. I had several places where I was doing intensive non-UI related tasks that really needed to be relegated to another thread but just hadn't gotten around to it. Imagine my surprise when I discovered I only needed to add a couple of lines of code!

BEFORE
Code:
[bundle extractArchive]; [self setDownloadStatus]; [self showGrowlMessage:@"Extract Complete"];

AFTER
Code:
dispatch_async(dispatch_get_global_queue(0, 0), ^{ [bundle extractArchive]; dispatch_async(dispatch_get_main_queue(), ^{ [self setDownloadStatus]; [self showGrowlMessage:@"Extract Complete"]; }); });
Could they have made it any easier?!? Granted my app will only work with Snow Leopard, but that's okay.

Anyone out there have any experience/tips with regard to GCD?
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:55 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2