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{
}