OC8_setter方法展开
2015-06-18 20:43
225 查看
// // Person.h // OC8_setter方法展开 // // Created by zhangxueming on 15/6/18. // Copyright (c) 2015年 zhangxueming. All rights reserved. // #import <Foundation/Foundation.h> #import "Dog.h" @interface Person : NSObject @property (copy, nonatomic) NSString *name; @property (assign, nonatomic) NSInteger age; @property (retain, nonatomic) Dog *dog; @end
// // Person.m // OC8_setter方法展开 // // Created by zhangxueming on 15/6/18. // Copyright (c) 2015年 zhangxueming. All rights reserved. // #import "Person.h" @implementation Person //copy展开 - (void)setName:(NSString *)name { if (_name != name) { [_name release]; _name = [name copy]; } } //assgin展开 - (void)setAge:(NSInteger)age { _age = age; } //retain展开 - (void)setDog:(Dog *)dog { if (_dog != dog) { [_dog release]; _dog = [dog retain]; } } - (void)dealloc { [_name release]; [_dog release]; [super dealloc]; } @end
// // Dog.h // OC8_setter方法展开 // // Created by zhangxueming on 15/6/18. // Copyright (c) 2015年 zhangxueming. All rights reserved. // #import <Foundation/Foundation.h> @interface Dog : NSObject @end // // Dog.m // OC8_setter方法展开 // // Created by zhangxueming on 15/6/18. // Copyright (c) 2015年 zhangxueming. All rights reserved. // #import "Dog.h" @implementation Dog @end
// // main.m // OC8_setter方法展开 // // Created by zhangxueming on 15/6/18. // Copyright (c) 2015年 zhangxueming. All rights reserved. // #import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool { // insert code here... NSLog(@"Hello, World!"); } return 0; }
相关文章推荐
- 用户需求调研报告
- html
- 图像处理
- resizableImageWithCapInsets认知和对@2x图片的理解
- 《人件》随笔之三
- IntelliJ Idea 常用快捷键列表
- linux习题
- OC7_复合类内存管理(setter方法)
- SQLite数据库的增删改查
- DynamicsAX 多个xpo的import
- 黑马程序员——JAVA多线程
- 2014赚钱项目 供应手机吸费 无风险生意
- 移动网站性能优化:网页加载技术概览
- 暴力移位法翻转字符串
- 超赞!聊聊WEB APP、HYBRID APP与NATIVE APP的设计差异
- 《人件》随笔之二
- 声讯电话平台 加值电话代理 电话吸费
- 安装Compass时不能访问服务器的问题
- 安装Compass时不能访问服务器的问题
- 回拨吸费手机 响一声电话吸费 电话群呼器