Objective-C
permits a class to entirely replace another class within an application.
The replacing class is said to “pose as” the target class. All messages sent to
the target class are then instead received by the posing class. There are some
restrictions on which classes can pose:
·A class may only pose as one of its direct or
indirect superclasses
·The posing class must not define any new
instance variables which are absent from the target class (though it may define
or override methods).
·No messages must have been sent to the target
class prior to the posing.
Posing,
similarly to categories, allows globally augmenting existing classes.
Posing permits two features absent from categories:
·A posing class can call overridden methods
through super, thus incorporating the implementation of the target class.
·A posing class can override methods defined in
categories.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Objective-C permits a class to entirely replace another class within an application. The replacing class is said to “pose as” the target class. All messages sent to the target class are then instead received by the posing class. There are some restrictions on which classes can pose:
· A class may only pose as one of its direct or indirect superclasses
· The posing class must not define any new instance variables which are absent from the target class (though it may define or override methods).
· No messages must have been sent to the target class prior to the posing.
Posing, similarly to categories, allows globally augmenting existing classes. Posing permits two features absent from categories:
· A posing class can call overridden methods through super, thus incorporating the implementation of the target class.
· A posing class can override methods defined in categories.