美文网首页
宏 - #define和typedef的用法

宏 - #define和typedef的用法

作者: js_huh | 来源:发表于2020-03-10 16:53 被阅读0次

#define是什么?

  • 宏定义语句
  • 通常用它来定义常量
  • 不在编译过程中进行,而是在这之前(预处理过程)就已经完成了.

怎么使用?

  • 定义一个宏 (用NameFont代替 [UIFont systemFontOfSize:16])
    #define NameFont [UIFont systemFontOfSize:16]
  • 使用宏的写法:
    NSDictionary *textAttr = @{NSFontAttributeName : NameFont};
  • 没使用宏的写法:
    NSDictionary *textAttr = @{NSFontAttributeName : [UIFont systemFontOfSize:16]};

也可以看看


参考

#ifndef, #define, #endif 作用
typedef和#define的用法与区别

相关文章

网友评论

      本文标题:宏 - #define和typedef的用法

      本文链接:https://www.haomeiwen.com/subject/gjasgctx.html