Objective-C 静态常量

1
2
3
// Constants.h
extern NSString * const MyOwnConstant;
extern NSString * const YetAnotherConstant;

最后,在Constants.m中通过赋值定义常量:

1
2
3
// Constants.m
NSString * const MyOwnConstant = @"myOwnConstant";
NSString * const  YetAnotherConstant = @"yetAnotherConstant";

 

内部常量:

定义在头文件的头部
test.h文件
#import <Foundation/Foundation.h>
static const int safety=5@interface test:NSObject{
 
}

 

posted on 2014-11-10 17:17  SCaptain  阅读(331)  评论(0编辑  收藏  举报

导航