< Previous PageNext Page > Hide TOC

Deprecated NSObject Methods

A method identified as deprecated has been superseded and may become unsupported in the future.

Deprecated in Mac OS X v10.5

poseAsClass:

Causes the receiving class to pose as a specified superclass. (Deprecated in Mac OS X v10.5.)

+ (void)poseAsClass:(Class)aClass

Parameters
aClass

A superclass of the receiver.

Discussion

The receiver takes the place of aClass in the inheritance hierarchy; all messages sent to aClass will actually be delivered to the receiver. The receiver must be defined as a subclass of aClass. It can’t declare any new instance variables of its own, but it can define new methods and override methods defined in aClass. The poseAsClass: message should be sent before any messages are sent to aClass and before any instances of aClass 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:

Special Considerations

Posing is deprecated in Mac OS X v10.5. The poseAsClass: method is not available in 64-bit applications on Mac OS X v10.5.

Availability
Declared In
NSObject.h

< Previous PageNext Page > Hide TOC


© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-02-04)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.