//声明一个int类型的变量a,变量初始化值为10,并且变量a左边有一个const关键字修饰 int const a = 10; //因为变量a被const修饰,就成为了只读,不能被修改赋值了,所以下面这行代码是错误的 a = 20;//错误代码 //上面第一句代码和这句代码是等价的,都是修饰变量a让其只读 const int a = 10;
int const *p // *p只读 ;p变量 int * const p // *p变量 ; p只读 const int * const p //p和*p都只读 int const * const p //p和*p都只读
//定义一个全局只读变量 NSString * const Kname = @"appkey"; //static修饰后此全局变量只能本文件访问 static NSString *const Key = @"hddjj”;
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
//声明一个局部变量i
int i = 0;
//每次点击view来到这个方法时让i自增
i ++;
//打印结果
NSLog(@"i=%d",i);
}
2016-10-26 14:58:48.290 fff[2760:170260] i=1 2016-10-26 14:58:49.044 fff[2760:170260] i=1 2016-10-26 14:58:49.200 fff[2760:170260] i=1 ....
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
//声明一个局部变量i
static int i = 0;
//每次点击view来到这个方法时让i自增
i ++;
//打印结果
NSLog(@"i=%d",i);
}
2016-10-26 15:07:34.276 fff[2817:175155] i=1 2016-10-26 15:07:35.347 fff[2817:175155] i=2 2016-10-26 15:07:35.761 fff[2817:175155] i=3 2016-10-26 15:07:36.057 fff[2817:175155] i=4 2016-10-26 15:07:36.415 fff[2817:175155] i=5 ....
+ (LoginTool *)sharedManager {
static dispatch_once_t oncePredicate;
dispatch_once(&oncePredicate, ^{
_sharedManager = [[self alloc] init];
});
return _sharedManager;
}
//声明一些全局常量 extern NSString * const name; extern NSInteger const count;
#import <Foundation/Foundation.h> //实现 NSString * const name = @"王五"; NSInteger const count = 3;
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有