MORuntimeUtilities


Discussion

Some handy functions and methods that deal with the Objective-C runtime.



Categories

NSBundle(MORuntimeUtilities)
NSBundle runtime extension methods.
NSObject(MORuntimeUtilities)
NSObject runtime extension methods.
Protocol(MORuntimeUtilities)
Protocol runtime extension methods.


Functions

MOFullMethodName
Pretty-formats a method name.
MOAllClasses
Returns an array of all the classes currently known to the Objective-C runtime. This function will never return _NSZombie or Object or any subclasses of Object. It will never return any classes that do not implement +retain and +release.
MOAllClassesImplementingInstanceSelector
Returns an array of all the classes whose instances implement a selector.
MOAllClassesImplementingFactorySelector
Returns an array of all the classes whose factories implement a selector.
MOKitAllowsMethodReplacement
Returns whether MOKit itself should enable features depending of method replacement.
MOKitSetAllowsMethodReplacement
Sets whether MOKit itself should enable features depending of method replacement.

MOAllClasses

Returns an array of all the classes currently known to the Objective-C runtime. This function will never return _NSZombie or Object or any subclasses of Object. It will never return any classes that do not implement +retain and +release.
MOKIT_EXTERN NSArray *MOAllClasses(
);
function result
The array of classes.

MOAllClassesImplementingFactorySelector

Returns an array of all the classes whose factories implement a selector.
MOKIT_EXTERN NSArray *
    MOAllClassesImplementingFactorySelector(
    SEL selector );

Given a selector, this function returns an array of all the classes whose factories (class objects) respond to that selector. This function will never return _NSZombie or Object or any subclasses of Object. It will never return any classes that do not implement +retain and +release.

Parameter Descriptions
selector
The selector.
function result
The array of classes.

MOAllClassesImplementingInstanceSelector

Returns an array of all the classes whose instances implement a selector.
MOKIT_EXTERN NSArray *
    MOAllClassesImplementingInstanceSelector(
    SEL selector );

Given a selector, this function returns an array of all the classes whose instances respond to that selector. This function will never return _NSZombie or Object or any subclasses of Object. It will never return any classes that do not implement +retain and +release.

Parameter Descriptions
selector
The selector.
function result
The array of classes.

MOFullMethodName

Pretty-formats a method name.
MOKIT_EXTERN NSString *MOFullMethodName(
    id self,
    SEL _cmd );

Given an object and a selector (usually passed as "self" and "_cmd"), this returns a pretty-formatted method name, suitable for error or log output. The result is of the form "-[NSString count]".

Parameter Descriptions
self
The object used to determine the class for the output.
_cmd
The selector used to determine the method for the output.
function result
The pretty-formatted string version of the method name.

MOKitAllowsMethodReplacement

Returns whether MOKit itself should enable features depending of method replacement.
MOKIT_EXTERN BOOL MOKitAllowsMethodReplacement(
);

Returns whether MOKit itself should enable features depending of method replacement. Note that this has no affect on the function of the method replacement API itself. Clients of MOKit may replace methods as they see fit, but any features of MOKit itself that use method replacement check this function. The function in turn looks at the value of the MOKitAllowsMethodReplacement user default which is YES by default. If it is set to NO, then MOKit will disable all method replacement features.

function result
YES if method replacement should be allowed, NO if not.

MOKitSetAllowsMethodReplacement

Sets whether MOKit itself should enable features depending of method replacement.
MOKIT_EXTERN void MOKitSetAllowsMethodReplacement(
    BOOL flag );

Sets whether MOKit itself should enable features depending of method replacement. Note that this has no affect on the function of the method replacement API itself. Clients of MOKit may replace methods as they see fit, but any features of MOKit itself that use method replacement will obey this setting. The function sets the value of the MOKitAllowsMethodReplacement user default which is YES by default. If it is set to NO, then MOKit will disable all method replacement features.

Note that since method replacement takes place at launch time for applications linked with MOKit and that it is not easily undoable, changes to this setting will take effect only the next time the application is launched.

Parameter Descriptions
flag
YES if method replacement should be allowed, NO if not.

(Last Updated 3/20/2005)