Private methods using Categories in Objective-C: calling super from a subclass -


How were the personal methods being implemented in objective-C () and raised a question in my mind:

How do you manage to enforce protected methods, i.e. private methods which are visible in subclasses?

Suppose I have a MySuperClass with one class that has all its own private methods, and I want to override one of MySuperClass private methods or call super I want to implement MySubclass. Is it possible (using categories in the direction of implementing personal methods)?

Take a look at some of these codes, the overwritten method below.

  // =============================== File: MySuperClass.h // = Interface for MySuperClass // =========================== @ interface MySuppressclass: object ... @ and // ==== ========================= File: MySuperClass.m // ================== ========= import "MySuperClass.h" // ======== For Private Methods ===================== ====== Interface // ================================= @ MySusuppress Class (private) - ( Zero) Private Instance Method; @end //====================================== // implementation of private methods // ============================================ MySuperClass implementation (private) - (void) Private instant method (// something) @end // ================================= ======= // Implementation for MySuperClass //== ========================= MySuperClass implementation ... @end // ========== ===================== FILE: MySubClass.h // = for MySubClass Interface // =========================== @MySubClass @ MySubClass: MySuperClass ... @end // ======== ======================== // IMPLICATION FOR MYSUBClass // ================= =============== Import MySubClass.h @ Implementation MySubClass // A Super No Except the G method. - (void) Private instant method [[Super Private Instance Mode]; // Compiler Error, Private Instance method is not showing! 

Cheers!

"post-text" itemprop = "text">

An approach Section 4.5:

... its bright The side is that you can also simulate in a safe way. For this, the author of a subclass should be informed in some way about preserved methods, and they have to be presented with compiler warnings. Alternatively, you can declare a protected range in a different interface file (for example, "PointProtected.h"), and it provides interface file with understanding that it is only by sub-class interface file Should be imported and used.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -