Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Apple recommend using a runloop over GCD for fetching multiple images?

Is it a good idea to load images (1 block each) through Grand Central Dispatch in iOS 4.0? (for use in a UITableView)

Why is a runloop preferred by Apple, as illustrated in the WWDC video sessions 207 and 208?

like image 210
Henry Avatar asked Aug 10 '10 02:08

Henry


2 Answers

The point being made in those videos was that Foundation networking does not integrate well with Grand Central Dispatch right now, so if you want to do Foundation-based networking a runloop is your best bet for avoiding the problems of traditional threads. However, in Session 206 - "Introducing Blocks and Grand Central Dispatch on iPhone", you'll see that they show an example of how to use GCD for just this purpose.

Me, I prefer GCD because of the elegance of the code and because (as they state in those videos) it is the way of the future.

like image 172
Brad Larson Avatar answered Nov 15 '22 08:11

Brad Larson


I haven't watched those videos yet, but here is what Chris Hanson (Apple Engineer) says about GCD vs NSOperation

Always use the highest-level abstraction available to you, and drop down to lower-level abstractions when measurement shows that they are needed.

In other words, you should be using NSOperations to do asynchronous processing (such as loading images for a table view) unless you have a good and necessary reason to go for GCD.

like image 20
Matt Long Avatar answered Nov 15 '22 08:11

Matt Long