1.沒有引數的block實現原理
1.1定義block變數


1.2.2block所佔位元組(__main_block_desc_0)賦值給DESC.
1.3block函式實現__main_block_func_0.



2.有引數的block實現原理
struct __test_block_impl_0 {
struct __block_impl impl;
struct __test_block_desc_0* Desc;
int age;(區域性變數)
int *height;(靜態區域性變數)(全域性變數不捕獲到block中)
__test_block_impl_0(void *fp, struct __test_block_desc_0 *desc, int _age, int *_height, int flags=0) : age(_age), height(_height) {
impl.isa = &_NSConcreteStackBlock;
impl.Flags = flags;
impl.FuncPtr = fp;
Desc = desc;
}
};
複製程式碼
self 在block中也是區域性變數,傳送訊息時預設是傳self,和sel(cmd)。
3.Block型別

