const的用法

用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";
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值