Causes the receiving class to pose as a specified superclass.
- macOS 10.0–10.5Deprecated
A superclass of the receiver.
The receiver takes the place of
a in the inheritance hierarchy; all messages sent to
a will actually be delivered to the receiver. The receiver must be defined as a subclass of
a. It can’t declare any new instance variables of its own, but it can define new methods and override methods defined in
pose message should be sent before any messages are sent to
a and before any instances of
a are created.
This facility allows you to add methods to an existing class by defining them in a subclass and having the subclass substitute for the existing class. The new method definitions will be inherited by all subclasses of the superclass. Care should be taken to ensure that the inherited methods do not generate errors.
A subclass that poses as its superclass still inherits from the superclass. Therefore, none of the functionality of the superclass is lost in the substitution. Posing doesn’t alter the definition of either class.
Posing is useful as a debugging tool, but category definitions are a less complicated and more efficient way of augmenting existing classes. Posing admits only two possibilities that are absent from categories:
A method defined by a posing class can override any method defined by its superclass. Methods defined in categories can replace methods defined in the class proper, but they cannot reliably replace methods defined in other categories. If two categories define the same method, one of the definitions will prevail, but there’s no guarantee which one.
A method defined by a posing class can, through a message to
super, incorporate the superclass method it overrides. A method defined in a category can replace a method defined elsewhere by the class, but it can’t incorporate the method it replaces.
Posing is deprecated in OS X v10.5. The
pose method is not available in 64-bit applications in OS X v10.5.