美文网首页
Extern的简单使用

Extern的简单使用

作者: 走在路上o | 来源:发表于2018-09-06 10:27 被阅读9次

写法:

#import <Foundation/Foundation.h>
extern  NSString  *const  PersonType;

@interface Person : NSObject

@end

------------------------------------
#import "Person.h"

NSString  *const  PersonType = @"都是男人";

@implementation Person

@end

  • 此时PersonType 这个常量字符串就对外公开了,要想获取的PersonType只需要import Person.h即可。
  • 命名时最好以类名为前缀,方便区分

相关文章

网友评论

      本文标题:Extern的简单使用

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