定义方式
> 1.宏 (缺点编译器不知道是常量)
#define MAXSIZE CGSizeMake(320, 480)
> 2. typedef
typedef CGSize MySizeType;
> 3.类内部使用
static CGSize const MAXSIZE = {320, 480};
> 4.全局
在.h中声明:extern CGSize const MAXSIZE;
在.m中初始化:CGSize const MAXSIZE = {320,480};
> 1.宏 (缺点编译器不知道是常量)
#define MAXSIZE CGSizeMake(320, 480)
> 2. typedef
typedef CGSize MySizeType;
> 3.类内部使用
static CGSize const MAXSIZE = {320, 480};
> 4.全局
在.h中声明:extern CGSize const MAXSIZE;
在.m中初始化:CGSize const MAXSIZE = {320,480};
本文标题:全局常量
本文链接:https://www.haomeiwen.com/subject/fqxkuqtx.html
网友评论