標籤:uicollection 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.
block 對象是一個C語言層級的文法和運行時特徵。他們和標準的C函數類似,但是除了包含可執行代碼,他們也可以包含stack(棧,系統自動管理記憶體)或者heap(堆,手動管理記憶體)中的記憶體的變數。一個block可以儲存一關於狀態(資料的)的設定,所以當執行的時候block可以使用這些設定來影響行為。
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.
你可以使用block來組合函數運算式來傳遞給API,隨意儲存,並被多個線程使用。block 經常被用作回呼函數,因為block同時具有執行回調的代碼和相應需要的資料。
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的文法實現了這個目標。
You should read this document to learn what block objects are and how you can use them from C, C++, or Objective-C.
你應該讀這篇文檔學習block對象是什麼,和你如何在C,C++,objective-c中使用block。
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.
文檔包括下列章節:
- Getting Started with Blocks 提供裡一個快速實用的block介紹
- Conceptual Overview 提供了一個概念性的block的介紹
- Declaring and Creating Blocks 告訴你如何定義和實現block
- Blocks and Variables 介紹了塊和變數之間的內在關係,和定義_block 儲存類型的修改
- Using Blocks 介紹了塊的不同的使用模式
本文原創,轉載請註明出處:http://blog.csdn.net/zhenggaoxing/article/details/44302505
IOS block編程指南 1 介紹