oc-15-self
2016-03-22 21:03
211 查看
// // Person.m // OC基础第三天 // // Created by apple on 15/10/17. // // #import "Person.h" @implementation Person // 让人运动 - (void)sport { // self:自己 // 本质:是1个指针. // 位置:方法中. // 在对象方法当中调用类方法 // 1.self在对象方法中,代表当前对象. // 2.self在类方法中,代表当前类. // 3.self访问成员变量 // self->成员变量名. [self eat]; self->_age = 10; NSLog(@"%d年龄的这个人运动--对象方法",self->_age); // Person *p = [Person new]; p->_age = 10; [p eat];//等同于上面 } // 让人吃 - (void)eat { NSLog(@"这个人吃东西--对象方法"); } // 让人运动 + (void)sport { NSLog(@"这个人运动--类方法"); [self eat]; // [Person eat];//等价于上面 } // 让人吃 + (void)eat { NSLog(@"这个人吃--类方法"); } @end
相关文章推荐
- Git使用说明
- VC定义超大数组时,stack OverFlow的解决方法
- Android 中对称加密算法DES,DESede,AES的加密和解密 的工具类的使用
- O2O、C2C、B2B、B2C的区别
- 视图之UITabBarController结构详解(侧重于文档分析)
- Menu菜单
- C++ 学习之路(10):继承与派生
- C++ 将数据导入到CSV,txt文档中
- socket:file descriptor exceeds limit (4096/4096)
- Spark Rpc通信源码分析
- JAVA实现网络爬虫
- The connection to adb is down, and a severe error has occured. You must restart adb and Eclipse.Ple
- RecyclerView使用详解(二)
- 链表题 java
- Linux基本的命令
- 地图2大头针
- 树的层次遍历_level
- BZOJ_P3594 [Scoi2014]方伯伯的玉米田(动态规划+二维树状数组优化)
- 判断txt文件的字符编码
- servlet相关介绍及乱码问题的解决方案