Index: src/OFArray.h ================================================================== --- src/OFArray.h +++ src/OFArray.h @@ -204,10 +204,28 @@ * \param separator The string with which the objects should be joined * \return A string containing all objects joined by the separator */ - (OFString*)componentsJoinedByString: (OFString*)separator; +/** + * Performs the specified selector on all objects in the array. + * + * \param selector The selector to perform on all objects in the array + */ +- (void)makeObjectsPerformSelector: (SEL)selector; + +/** + * Performs the specified selector on all objects in the array with the + * specified object. + * + * \param selector The selector to perform on all objects in the array + * \param obj The object to perform the selector with on all objects in the + * array + */ +- (void)makeObjectsPerformSelector: (SEL)selector + withObject: (id)obj; + #ifdef OF_HAVE_BLOCKS /** * Executes a block for each object. * * \param block The block to execute for each object Index: src/OFArray.m ================================================================== --- src/OFArray.m +++ src/OFArray.m @@ -418,10 +418,29 @@ * would create a real copy each time -[copy] is called. */ ret->isa = [OFString class]; return ret; } + +- (void)makeObjectsPerformSelector: (SEL)selector +{ + id *objs = [array cArray]; + size_t i, count = [array count]; + + for (i = 0; i < count; i++) + ((void(*)())[objs[i] methodForSelector: selector])(); +} + +- (void)makeObjectsPerformSelector: (SEL)selector + withObject: (id)obj +{ + id *objs = [array cArray]; + size_t i, count = [array count]; + + for (i = 0; i < count; i++) + ((void(*)(id))[objs[i] methodForSelector: selector])(obj); +} - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state objects: (id*)objects count: (int)count_ {