Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -79,10 +79,42 @@ * \param selector The selector which should be checked for respondance * \return A boolean whether the objects responds to the specified selector */ - (BOOL)respondsToSelector: (SEL)selector; +/** + * Performs the specified selector. + * + * \param selector The selector to perform + * \return The object returned by the method specified by the selector + */ +- (id)performSelector: (SEL)selector; + +/** + * Performs the specified selector with the specified object. + * + * \param selector The selector to perform + * \param obj The object that is passed to the method specified by the selector + * \return The object returned by the method specified by the selector + */ +- (id)performSelector: (SEL)selector + withObject: (id)obj; + +/** + * Performs the specified selector with the specified objects. + * + * \param selector The selector to perform + * \param obj1 The first object that is passed to the method specified by the + * selector + * \param obj2 The second object that is passed to the method specified by the + * selector + * \return The object returned by the method specified by the selector + */ +- (id)performSelector: (SEL)selector + withObject: (id)obj1 + withObject: (id)obj2; + /** * Checks two objects for equality. * * Classes containing data (like strings, arrays, lists etc.) should reimplement * this! Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -479,10 +479,34 @@ return objc_msg_lookup(self, selector); #else return class_getMethodImplementation(isa, selector); #endif } + +- (id)performSelector: (SEL)selector +{ + id (*imp)() = (id(*)())[self methodForSelector: selector]; + + return imp(); +} + +- (id)performSelector: (SEL)selector + withObject: (id)obj +{ + id (*imp)(id) = (id(*)(id))[self methodForSelector: selector]; + + return imp(obj); +} + +- (id)performSelector: (SEL)selector + withObject: (id)obj1 + withObject: (id)obj2 +{ + id (*imp)(id, id) = (id(*)(id, id))[self methodForSelector: selector]; + + return imp(obj1, obj2); +} - (const char*)typeEncodingForSelector: (SEL)selector { #if defined(OF_OBJFW_RUNTIME) const char *ret;