Objective-C基礎學習之Super關鍵字

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在類方法中,那么就會調用父類的類方法
  • 使用場合:
    • 子類重寫父類的方法時想保留父類的一些行為
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容