Block objects are a C-level syntactic and runtime feature. They are similar to standard C functions, but in addition to executable code they may also contain variable bindings to automatic (stack) or managed (heap) memory. A block can therefore maintain a set of state (data) that it can use to impact behavior when executed.html
block 對象是一個C語言級別的語法和運行時特徵。他們和標準的C函數相似,可是除了包含可執行代碼,他們也能夠包含stack(棧,系統自動管理內存)或者heap(堆,手動管理內存)中的內存的變量。一個block能夠保存一關於狀態(數據的)的設置,因此當執行的時候block能夠使用這些設置來影響行爲。ios
You can use blocks to compose function expressions that can be passed to API, optionally stored, and used by multiple threads. Blocks are particularly useful as a callback because the block carries both the code to be executed on callback and the data needed during that execution.objective-c
你能夠使用block來組合函數表達式來傳遞給API,隨意存儲,並被多個線程使用。block 常常被用做回調函數,由於block同時具備執行回調的代碼和相應須要的數據。express
Blocks are available in GCC and Clang as shipped with the OS X v10.6 Xcode developer tools. You can use blocks with OS X v10.6 and later, and iOS 4.0 and later. The blocks runtime is open source and can be found in LLVM’s compiler-rt subproject repository. Blocks have also been presented to the C standards working group as N1370: Apple’s Extensions to C. As Objective-C and C++ are both derived from C, blocks are designed to work with all three languages (as well as Objective-C++). The syntax reflects this goal.編程
block在OS X 10.6 中的Xcode 開發者工具中的gcc 和clang是容許的。你能夠在OS X v10.6 和 IOS 4.0 及之後版本中使用block。block運行時是開源的 你能夠在LLVM’s compiler-rt subproject repository中找到 。block也在標準C工做中有展現見:N1370: Apple’s Extensions to C。由於objective-C和C++都是來源於C,block被設計成能夠在這三種語言中運行(也能夠在Objective-C++)。block的語法實現了這個目標。app
You should read this document to learn what block objects are and how you can use them from C, C++, or Objective-C.ide
你應該讀這篇文檔學習block對象是什麼,和你如何在C,C++,objective-c中使用block。svn
Organization of This Document (block文檔的組織)函數
This document contains the following chapters:工具
Getting Started with Blocks provides a quick, practical, introduction to blocks.
Conceptual Overview provides a conceptual introduction to blocks.
Declaring and Creating Blocks shows you how to declare block variables and how to implement blocks.
Blocks and Variables describes the interaction between blocks and variables, and defines the __block
storage type modifier.
Using Blocks illustrates various usage patterns.
1: IOS block編程指南 1 介紹
block編程簡介
2: IOS block編程指南 2 block開始
提供裏一個快速實用的block介紹
3:IOS block編程指南 3 概念總覽
提供了一個概念性的block的介紹
4:IOS block編程指南 4 聲明和建立blocks
告訴你如何定義和實現block
5:IOS block編程指南 5 Block和變量
介紹了塊和變量之間的內在關係,和定義_block 存儲類型的修改
6:IOS block編程指南 6 Block的使用
Block使用相關