문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top