Blocks编程要点
Blocks编程要点(中文3400字,英文3300字)
文章出处:Apple Inc.
摘要:本文简要的介绍iOS4.0新特性Blocks编程的要点,即Block入门,概念概述,声明和创建Blocks,Blocks和变量四大部分,本文档中包含许多原则或准则,并通过举例的方式对原则进行解释说明。
关键字:Blocks 对象 iOS
原文:
Introduction
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.
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. [资料来源:http://www.doc163.com]