---
title: "Objective-C : Posing"  
description: "Previously we learn how to add methods from outside the class : Objective-C : Categories  Objective-C permits a class to wholly replace another class"  
author: "Anonymous User"  
published: 2015-07-17  
updated: 2018-03-13  
canonical: https://www.mindstick.com/blog/10926/objective-c-posing  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 2 minutes  

---

# Objective-C : Posing

Previously we learn how to add methods from [outside the class](https://www.mindstick.com/interview/2468/can-you-access-the-private-method-from-outside-the-class) : Objective-C : [Categories](https://answers.mindstick.com/qa/47601/what-are-the-categories-of-stations-for-provision-of-passenger-amenities-explain-them)\

Objective-C permits a class to wholly replace another class within a program. The replacing class is said to "pose as" the target class.

Note: Class posing was declared [deprecated](https://www.mindstick.com/forum/972/deprecated-as-a-property-in-sencha-touch) with [Mac OS](https://www.mindstick.com/forum/23311/mod_rest-on-ejabberd-15-0-4-on-mac-os-x-yosemite-is-not-starting) X v10.5, and is unavailable in the 64-bit runtime.

For the versions still supporting posing, all [messages sent](https://answers.mindstick.com/qa/115829/facebook-messenger-messages-sent-but-not-delivered-for-days) to the target class are instead received by the posing class.

##### There are several restrictions

• A class may only pose [as one](https://answers.mindstick.com/qa/34642/which-indian-it-company-has-been-recognized-as-one-of-the-world-s-best-employers-by-the-top-employer-institute-for-the-third-consecutive-year) of its direct or indirect superclasses.

• The posing class must not define any new [instance variables](https://www.mindstick.com/forum/34631/instance-variables-and-class-variables) that are absent from the target class (though it may define or override methods).

• The target class may not have received any messages prior to the posing.

• Posing, similarly with categories, allows global augmentation of existing classes. Posing permits two [features](https://www.mindstick.com/articles/12993/5-advanced-features-for-your-odoo-ecommerce-theme) absent from categories:

• A posing class can call overridden methods through super, thus incorporating the [implementation](https://www.mindstick.com/forum/33764/how-to-implementation-of-class-in-c-sharp) of the target class.

• A posing class can override methods defined in categories\

##### For example,

```
@interface CustomNSApplication : NSApplication@end @implementation CustomNSApplication- (void) setMainMenu: (NSMenu*) menu{     // do something with menu}@end class_poseAs ([CustomNSApplication class], [NSApplication class]);
```

This intercepts every invocation of setMainMenu to NSApplication. \

---

Original Source: https://www.mindstick.com/blog/10926/objective-c-posing

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
