1.block
为什么用block?和函数有很多相似之处,但是绝对不是函数.
^{
语句体;
}
函数是不允许嵌套定义的.也就是不允许在函数的定义里再去定义一个函数.
block可以在函数的定义里定义.
int(^mathBlock)(int x,int y);
mathBlock是block类型的变量
typedef int(^mathBlock)(int x,int y);
mathBlock类型的别名.int(^)(int x,int y);
2.typedef 的使用
2.1.int count;count是整形类型的变量
2.2.typedef int count; count是整形类型的别名.
2.3.count i; 那么i就是count类型的,也就是int类型的.
2.3. char *str_t; str_t 指针类型的变量
2.4. typedef char *str_t ;str_t 是指针类型
3.struct student
{
int num;
int age;
};
typedef struct student stu_t;
stu_t是类型,完全等价于struct student;
typedef stu_t * st_p;
st_p 完全等价于struct student *;
st_p st;
typedef {
int num;
int age;
}stu_t;
stu_t st;
4.block语句块可以访问外部的局部变量,但是只能读取,不能写入,如果想写入,需要在变量声明的前边加上__block注明.