Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -66,10 +66,17 @@ * * \return A boolean whether the class conforms to the specified protocol */ + (BOOL)conformsToProtocol: (Protocol*)protocol; +/** + * \param selector The selector for which the method should be returned + * + * \return The implementation of the instance method for the specified selector + */ ++ (IMP)instanceMethodForSelector: (SEL)selector; + /** * Replace a method implementation with another implementation. * * \param selector The selector of the method to replace * \param imp The new implementation for the method Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -128,10 +128,19 @@ return YES; return NO; #endif } + ++ (IMP)instanceMethodForSelector: (SEL)selector +{ +#ifdef __objc_INCLUDE_GNU + return method_get_imp(class_get_instance_method(self, selector)); +#else + return class_getMethodImplementation(self, selector); +#endif +} + (IMP)setImplementation: (IMP)newimp forMethod: (SEL)selector { #ifdef __objc_INCLUDE_GNU