/* Working with Classes */ /** * Returns the name of a class. * * @param cls A class object. * * @return The name of the class, or the empty string if \e cls is \c Nil. */ OBJC_EXPORT const char *class_getName(Class cls) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); /** * Returns a Boolean value that indicates whether a class object is a metaclass. * * @param cls A class object. * * @return \c YES if \e cls is a metaclass, \c NO if \e cls is a non-meta class, * \c NO if \e cls is \c Nil. */ OBJC_EXPORT BOOL class_isMetaClass(Class cls) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); /** * Returns the superclass of a class. * * @param cls A class object. * * @return The superclass of the class, or \c Nil if * \e cls is a root class, or \c Nil if \e cls is \c Nil. * * @note You should usually use \c NSObject‘s \c superclass method instead of this function. */ OBJC_EXPORT Class class_getSuperclass(Class cls) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); /** * Sets the superclass of a given class. * * @param cls The class whose superclass you want to set. * @param newSuper The new superclass for cls. * * @return The old superclass for cls. * * @warning You should not use this function. */ OBJC_EXPORT Class class_setSuperclass(Class cls, Class newSuper) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_5, __IPHONE_2_0,__IPHONE_2_0); /** * Returns the version number of a class definition. * * @param cls A pointer to a \c Class data structure. Pass * the class definition for which you wish to obtain the version. * * @return An integer indicating the version number of the class definition. * * @see class_setVersion */ OBJC_EXPORT int class_getVersion(Class cls) __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0); /** * Sets the version number of a class definition. * * @param cls A pointer to an Class data structure. * Pass the class definition for which you wish to set the version. * @param version An integer. Pass the new version number of the class definition. * * @note You can use the version number of the class definition to provide versioning of the * interface that your class represents to other classes. This is especially useful for object * serialization (that is, archiving of the object in a flattened form), where it is important to * recognize changes to the layout of the instance variables in different class-definition versions. * @note Classes derived from the Foundation framework \c NSObject class can set the class-definition * version number using the \c setVersion: class method, which is implemented using the \c class_setVersion function. */ OBJC_EXPORT void class_setVersion(Class cls, int version) __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0); /** * Returns the size of instances of a class. * * @param cls A class object. * * @return The size in bytes of instances of the class \e cls, or \c 0 if \e cls is \c Nil. */ OBJC_EXPORT size_t class_getInstanceSize(Class cls) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
时间: 2024-10-12 20:33:10