ftp.nice.ch/pub/next/developer/resources/classes/misckit/MiscKit.1.10.0.s.gnutar.gz#/MiscKit/Documentation/Categories/MiscRuntimeExtensions.rtf

This is MiscRuntimeExtensions.rtf in view mode; [Download] [Up]

Release 1.0  Copyright ©1994 by Don Yacktman.  All Rights Reserved.






Object (MiscRuntimeExtensions)






Declared In:	<misckit/MiscRuntimeExtensions.h>





Category Description

This category methods to the Object class which extend the runtime.  Use +instanceSize to determine the size of an instance of a particular class.  Use ±becomeClass: to change the class of an object.  Use ±compare: to compare two different objects, as you would with ±isEqual.





Method Types

Determining the size of an object	+ instanceSize
	± instanceSize
	± sizeOf

Changing an object's class	- becomeClass:

Comparing objects	- compare:





Class Methods

instanceSize
+  (int)instanceSize

Returns the size of an instance of the receiving class.  Note that an Objective±C class is represented by the compiler as a C structure.  This method returns the size of that structure, but does not return any information about data that instance variables may point to, which means that memory allocated by this object is not taken into consideration.

See also:  ± instanceSize and ± sizeOf





Instance Methods

becomeClass
±  becomeClass:aClass

Changes the receiver into an object of class aClass, where aClass is an Objective-C Class object.  Returns self if successful or nil if unsuccessful.  Note that you cannot change a class into a class of larger size, though you can change a class into a class of a smaller size.  (You can compare sizes using the ±instanceSize method.)  One known bug is that after changing to a class of a smaller size you cannot change back to the original class.  This happens because the old size information is thrown out.  If you know that you can move to a larger class size safely, then you can call the ±_becomeClass: version instead to bypass range checking.  Warning:  This method is extremely dangerous.  If used without knowing what it does it may likely cause crashes.  Despite all this warning, this method can be invaluable and useful in some situations.  The user simply must take all responsibility for the outcome of this method if they use it, as the author disclaims any and all responsibility!

See also:  ± class (Object)




compare
±  (int)compare:anObject

Attempts to compare two objects.  Returns zero (0) if they compare as ªequalº, one (1) if the receiver is ªgreaterº than anObject or a negative one (-1) if the receiver is ªlessº than anObject.  The default implementation attempts to compare string values (as obtained with ±stringValue) of two objects.  Subclasses should override this if there is a more useful comparison possible.

See also:  ± isEqual: (Object), strcmp()




instanceSize
±  (int)instanceSize

Returns the size of an instance of the receiving class.  Note that an Objective±C class is represented by the compiler as a C structure.  This method returns the size of that structure, but does not return any information about data that instance variables may point to, which means that memory allocated by this object is not taken into consideration.  This method should not be overridden.  If the implementation is changed, methods which depend upon this behavior will break, such as ±becomeClass:.  If a method which gives complete size information is desired, use ±sizeOf.

See also:  + instanceSize and ± sizeOf




sizeOf
±  (int)sizeOf

Returns the size of an instance.  This may be overridden to take into account the space taken up by allocated memory such as string pointers and objects pointed to (in composite objects).

See also:  + instanceSize and ± instanceSize




These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.