1.在用@property声明的时候传入retian这个参数
@property (retain)Book *book; //代表该成员变量会进行内存管理也就是在编译的时候会在.m文件中生成如下代码,先release旧的,再retain新的
-(void)setBook:(Book *)book{ if(_book!=book){ [_book release]; _book=[book retain]; } } |
@property (assign)int age; |
@property (readwrite)int age; |
@property (nonatomic)int age; |
@property (nonatomic,getter = isDelete)BOOL isDelete;//表示生成get方法的时候方法名是isDelete |
原文:http://blog.csdn.net/cooljune/article/details/18848277