This document discusses blocks and Grand Central Dispatch (GCD) in Objective-C. It introduces blocks as closures that can be passed around like objects, explains their advantages over function pointers, and demonstrates their use. It also outlines the key components of GCD including main dispatch queues, concurrent queues, serial queues, groups to synchronize work, and sources to integrate events. Sample code is provided to demonstrate blocks and GCD.
21. •
• Introducing Blocks and Grand Central Dispatch
• Concurrency Programming Guide
• Grand Central Dispatch (GCD) Reference
• WWDC 2010: Session 206, 211
Notas del editor
\n
Blocks和GCD作为Objective-C和Cocoa的特性,最早在Mac OS X 10.6 Snow Leopard引入。iPhone从iOS 4开始支持。主要用于解决异步问题。\n
Main dispatch queue是一个全局串行队列,在应用的主run loop中。\n