iOS 头文件 只读属性
2017-05-22 18:45
190 查看
//头文件
//@property (nonatomic, readonly) UIView *headView;
#import "ViewController.h"
@interface ViewController ()
{
UIView *_headView;
}
@end
@implementation ViewController
//MRC
//@property 特性是由xcode自动生成setter和getter方法的声明
//@synthesize 特性是由xcode自动生成setter和getter方法的定义
//在ARC下,@property则做了2件事:
//1. 由@property声明的属性,在编译时刻为其生成成员变量(_XXX),除非,声明一个与属性同名的成员变量,则不会自动生成相应的_XXX成员变量。
//2. 由@property声明的属性,在编译时刻为其生成getter和setter方法的声明与定义。
//Objective-C语言,通过@synthesize生成getter和setter方法.
@synthesize headView = _headView;
- (void)viewDidLoad {
_headView = [UIView new];
_headView.frame = self.view.bounds;
[self.view addSubview:_headView];
[super viewDidLoad];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
self.headView.backgroundColor = [UIColor cyanColor];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
//@property (nonatomic, readonly) UIView *headView;
#import "ViewController.h"
@interface ViewController ()
{
UIView *_headView;
}
@end
@implementation ViewController
//MRC
//@property 特性是由xcode自动生成setter和getter方法的声明
//@synthesize 特性是由xcode自动生成setter和getter方法的定义
//在ARC下,@property则做了2件事:
//1. 由@property声明的属性,在编译时刻为其生成成员变量(_XXX),除非,声明一个与属性同名的成员变量,则不会自动生成相应的_XXX成员变量。
//2. 由@property声明的属性,在编译时刻为其生成getter和setter方法的声明与定义。
//Objective-C语言,通过@synthesize生成getter和setter方法.
@synthesize headView = _headView;
- (void)viewDidLoad {
_headView = [UIView new];
_headView.frame = self.view.bounds;
[self.view addSubview:_headView];
[super viewDidLoad];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
self.headView.backgroundColor = [UIColor cyanColor];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
相关文章推荐
- VB-改变文件只读属性
- Attrib 显示、设置或删除指派给文件或目录的只读、存档、系统以及隐藏属性
- 在VC中,如何修改文件的只读属性设置
- java 设置文件只读属性
- iphone ios 文件系统操作(创建、删除,修改,获取属性)
- 更改只读文件属性为正常
- 删除文件夹及其子文件,包括只读属性的文件和文件夹
- C# 去除文件和文件夹的只读属性
- 用程序去掉文件和文件夹的只读属性
- java设置文件属性(隐藏,只读...)
- Perl 将只读文件属性改成可写文件属性
- 如何使文件上传输入框为只读属性
- 在ASP.NET去掉文件的只读属性
- C# 去除文件和文件夹的只读属性
- 在VC中,如何修改文件的只读属性设置(转)
- 设置上传文件控件文本框只读属性代码
- python 中移去文件的只读属性
- 修改文件(文件夹)的属性(隐藏,只读,存档,创建时间,最后访问时间,最后修改时间)
- 文件删除不了,文件粉碎也不行,去不掉只读属性,F8安全模式下也删不掉,参数不正确
- iOS Data Storage Guidelines 和 "do not back up"文件属性