extern的作用是使用外部文件创建的属性
若一个文件的某个属性允许外部文件访问,则必须将相关属性定义在.m的@implementation外面,不能定义在.h里面。



说说extern与static的区别
全局属性是定义在@implementation外的属性,分为私有全局属性和共有全局属性,私有全局属性使用static修饰,公有全局属性不用关键字修饰,但如果外部文件要使用这个属性时需要声明名称和类型一样的属性,并且要在声明前面使用extern关键字修饰。


extern的作用是使用外部文件创建的属性
若一个文件的某个属性允许外部文件访问,则必须将相关属性定义在.m的@implementation外面,不能定义在.h里面。
说说extern与static的区别
全局属性是定义在@implementation外的属性,分为私有全局属性和共有全局属性,私有全局属性使用static修饰,公有全局属性不用关键字修饰,但如果外部文件要使用这个属性时需要声明名称和类型一样的属性,并且要在声明前面使用extern关键字修饰。
本文标题:extern 和static在OC中的使用
本文链接:https://www.haomeiwen.com/subject/qqektqtx.html
网友评论