property、synthesize、id
1、@property int age;
@synthesize age = _age;
//注意:必须在非ARC下,在“项目——》building setting——》all——》objcet-C Automic Reference Counting
//@property(nonatomic,retain) NSString *name相当于:
- (void)setName:(NSString *)name
{
if (_name != name)
{
[_name release];
_name = [name retain];
}
}
_name = [name retain];
// @property:可以自动生成某个成员变量的setter和getter声明
@property int age;
//- (void)setAge:(int)age;
//- (int)age;
@property int height;
//- (void)setHeight:(int)height;
//- (int)height;
@property(nonatomic,copy)NSString *name;
@property(nonatomic,retain)NSArray *group;
@synthesize age = _age;
{
//int _speed;
//int _wheels;
}
@property int speed;
@property int wheels;
//@property int speed, wheels;
- (void)test;
@end
@implementation Car
//@synthesize speed = _speed, wheels = _wheels;
// 注意:会访问_speed这个成员变量,如果不存在,就会自动生成@private类型的_speed变量
@synthesize speed = _speed;
@synthesize wheels = _wheels;
- (void)test
{
NSLog(@"速度=%d", _speed);
}
@end
@property int age;
property、synthesize、id的更多相关文章
- IOS 关键字self,super,copy, retain, assign , readonly , readwrite, nonatomic、 @synthesize、@property、@dynamic
IOS 关键字self,super,copy, retain, assign , readonly , readwrite, nonatomic. @synth ...
- iOS 内存管理-copy、 retain、 assign 、readonly 、 readwrite、nonatomic、@property、@synthesize、@dynamic、IB_DESIGNABLE 、 IBInspectable、IBOutletCollection
浅谈iOS内存管理机制 alloc,retain,copy,release,autorelease 1)使用@property配合@synthesize可以让编译器自动实现getter/setter方 ...
- Objective-C 点语法 成员变量的作用域 @property和@synthesize关键字 id类型
点语法 1.利用点语法替换set方法和get方法 方法调用 Student *stu = [Student new]; [stu setAge : 18]; int age = [stu age]; ...
- OC的特有语法-分类Category、 类的本质、description方法、SEL、NSLog输出增强、点语法、变量作用域、@property @synthesize关键字、Id、OC语言构造方法
一. 分类-Category 1. 基本用途:Category 分类是OC特有的语言,依赖于类. ➢ 如何在不改变原来类模型的前提下,给类扩充一些方法?有2种方式 ● 继承 ● 分类(Categor ...
- @property、@synthesize和dynamic的用法
原文: http://blog.csdn.net/hherima/article/details/8622948 @代表“Objective-C”的标志,证明您正在使用Objective-C语言 O ...
- ios中点语法、property跟synthesize用法
一:OC中得点语法 1> 点语法的基本使用: ·使用 对象.成员变量 可以实现设置成员变量值,和获取成员变量的值 2> 点语法的本质 (点语法是Xcode编译器自己帮我们完成的一个 ...
- OC语言@property @synthesize和id
OC语言@property @synthesize和id 一.@property @synthesize关键字 注意:这两个关键字是编译器特性,让xcode可以自动生成getter和setter的声明 ...
- 李洪强iOS开发之OC语言@property @synthesize和id
OC语言@property @synthesize和id 一.@property @synthesize关键字 注意:这两个关键字是编译器特性,让xcode可以自动生成getter和setter的声明 ...
- 「OC」@property @synthesize和id
一.@property @synthesize关键字 这两个关键字是编译器特性,让Xcode可以自动生成getter和setter. (一)@property 关键字 @property 关键字可以自 ...
随机推荐
- 使用 hibernate 存取大对象数据类型(clob和blob)
数据库表如下: book表 id 该表的主键.number类型. photo 代表图书的图片,blob类型. description 图书的描述,clob类型. 使用 hibernate3 往 boo ...
- Struts2 访问web元素
访问web元素的四种方法(耦合,依赖注入).(耦合,非依赖注入).(非耦合,依赖注入).(非耦合,非依赖注入) 耦合:可以得到HttpServletResponse,HttpServletReques ...
- ajax 实现异步请求
ajax实现异步请求: function onclicks() { $.ajax( { url:'../hhh/columnSearch.do',// 跳转到 action // data: {tab ...
- jsoup 解析html 页面数据
我html 页面元素: /html/body/table[2]/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/font/html/body/table[2]/tbody ...
- c++ :OOP之静态类型与动态类型
所谓静态类型即类型指针或引用的字面类型:而动态类型即类型指针或引用的实际类型. 这一对概念一般发生在基类和派生类之间. 如: class Base { ..... } class Derived : ...
- Android Studio 实时显示布局文件Preview窗口
Android Studio的功能包含preview窗口, 可以查看布局(layout)的样式; 位置:app->src->main->res(资源)->layout(布局), ...
- Android_自定义进度条
转载:http://blog.csdn.net/lmj623565791/article/details/43371299 ,本文出自:[张鸿洋的博客] 1.概述 最近需要用进度条,秉着不重复造轮子的 ...
- zrender源码分析1:总体结构
开始 zrender(Zlevel Render) 是一个轻量级的Canvas类库,这里是GitHub的网址 点我, 类似的类库有Kinetic.JS.EaselJS. 但貌似都没有zrender好用 ...
- Linux 计算某文件夹下的所有文件的md5值
使用find 命令 find /root -type f -print0 |xargs -0 md5sum >a.md5 校验的话 md5sum -c a.md5
- secedit
secedit /export /cfg mytemplate.inf /log mylog.txt http://www.oracle-base.com/dba/script.php?categor ...