大佬教程收集整理的这篇文章主要介绍了ios – 类中的extern NSString * const.,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
#import <Foundation/Foundation.h> @interface PCConstants : NSObject extern NSString *const kPCUserProfileKey; extern NSString *const kPCUserProfilenameKey; extern NSString *const kPCUserProfileFirstNameKey; extern NSString *const kPCUserProfileLOCATIOnKey; extern NSString *const kPCUserProfilegenderKey; extern NSString *const kPCUserProfileBirthDayKey; extern NSString *const kPCUserProfileInterestedInKey; @end
执行:
#import "PCConstants.h" @implementation PCConstants NSString *const kPCUserProfileKey = @"profile"; NSString *const kPCUserProfilenameKey = @"name"; NSString *const kPCUserProfileFirstNameKey = @"firstname"; NSString *const kPCUserProfileLOCATIOnKey = @"LOCATIOn"; NSString *const kPCUserProfilegenderKey = @"gender"; NSString *const kPCUserProfileBirthDayKey = @"birthday"; NSString *const kPCUserProfileInterestedInKey = @"interestedIn"; @end
当我在.pch文件中导入头文件时,我可以在任何地方访问常量.但我试着了解发生了什么.
我从不为此对象分配init,因此它们不能是实例常量.所以常量必须是“类对象常量对吗?但我认为类对象不能包含数据.
谁能解释一下?
以上是大佬教程为你收集整理的ios – 类中的extern NSString * const.全部内容,希望文章能够帮你解决ios – 类中的extern NSString * const.所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。