Objective-C基础学习之Super关键字
1.super基本概念
- 【Objective-C基础学习之Super关键字】super是个编译器的指令符号,只是告诉编译器在执行的时候,去调谁的方法.
- self是一个隐私参数;
self refers to the object receiving a message in objective-C programming.
- super 并不是隐藏的参数,它只是一个“编译器指示符”,它和 self 指向的是相同的消息接收者
super is a flag that tells the compiler to search for the method implementation in a very different place. It begins in the superclass of the class that defines the method where super appears.
2.super的作用
+ 1.直接调用父类中的某个方法
+ 2.super在对象方法中,那么就会调用父类的对象方法
super在类方法中,那么就会调用父类的类方法
- 使用场合:
- 子类重写父类的方法时想保留父类的一些行为
推荐阅读
- 慢慢的美丽
- EffectiveObjective-C2.0|EffectiveObjective-C2.0 笔记 - 第二部分
- 开学第一天(下)
- 奔向你的城市
- 学无止境,人生还很长
- 由浅入深理解AOP
- “成长”读书社群招募
- 继续努力,自主学习家庭Day135(20181015)
- python学习之|python学习之 实现QQ自动发送消息
- 每日一话(49)——一位清华教授在朋友圈给大学生的9条建议