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使用相关