用const修饰的变量就变成了常量了
1. const int a = 1; a是常量,不能够再变
2. int const a = 1; a是常量,不能够再变
3. int const *b = &a; *b是常量,不能够再变
4.const int *b = &a; *b是常量,不能够再变
5.NSString * const CJAppSecret = @”abcd”; CJAppSecret是常量,不能够再变
当我们自己发送通知的时候,附上通知名字,通知名字可以写成宏,写在pch中,方便使用,但是我们最好仿照苹果写通知名称的方法
自己写一个CJConst,
.h中:
#import <Foundation/Foundation.h>
// 账号信息
extern NSString * const HWAppKey;
extern NSString * const HWRedirectURI;
extern NSString * const HWAppSecret;
// 通知
// 表情选中的通知
extern NSString * const HWEmotionDidSelectNotification;
extern NSString * const HWSelectEmotionKey;
// 删除文字的通知
extern NSString * const HWEmotionDidDeleteNotification;
.m中:
//用到了NSString,所以导入Foundation,否则什么也不需要
#import <Foundation/Foundation.h>
// 账号信息
NSString * const HWAppKey = @"874136418";
NSString * const HWRedirectURI = @"http://www.baidu.com";
NSString * const HWAppSecret = @"341afc57b7071e8ea601d734309dd954";
// 通知
// 表情选中的通知
NSString * const HWEmotionDidSelectNotification = @"HWEmotionDidSelectNotification";
NSString * const HWSelectEmotionKey = @"HWSelectEmotionKey";
// 删除文字的通知
NSString * const HWEmotionDidDeleteNotification = @"HWEmotionDidDeleteNotification";