1.super基本概念
-
super是個編譯器的指令符號,只是告訴編譯器在執(zhí)行的時候,去調誰的方法.
- self是一個隱私參數(shù);
self refers to the object receiving a message in objective-C programming.
- super 并不是隱藏的參數(shù),它只是一個“編譯器指示符”,它和 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在類方法中,那么就會調用父類的類方法
- 使用場合:
- 子類重寫父類的方法時想保留父類的一些行為