From 3dbddcf1862dbc96f499dc2f989f1266a514043d Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Fri, 30 Oct 2009 18:02:33 -0700 Subject: [PATCH] Added makeObjectsPerformSelector:withObjects:. Reviewed by me. --- AppKit/CPMenu.j | 11 ++++++++--- Foundation/CPArray.j | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/AppKit/CPMenu.j b/AppKit/CPMenu.j index ad0e2dad7..37e55757a 100644 --- a/AppKit/CPMenu.j +++ b/AppKit/CPMenu.j @@ -1050,7 +1050,7 @@ var STICKY_TIME_INTERVAL = 500, [_menuView setFont:aFont]; } -- (void)setBackgroundStyle:(_CPMenuWindowBackgroundStyle)aBackgroundStyle ++ (CPColor)backgroundColorForBackgroundStyle:(_CPMenuWindowBackgroundStyle)aBackgroundStyle { var color = _CPMenuWindowBackgroundColors[aBackgroundStyle]; @@ -1092,8 +1092,13 @@ var STICKY_TIME_INTERVAL = 500, _CPMenuWindowBackgroundColors[aBackgroundStyle] = color; } - - [self setBackgroundColor:color]; + + return color; +} + +- (void)setBackgroundStyle:(_CPMenuWindowBackgroundStyle)aBackgroundStyle +{ + [self setBackgroundColor:[[self class] backgroundColorForBackgroundStyle:aBackgroundStyle]]; } - (void)setMenu:(CPMenu)aMenu diff --git a/Foundation/CPArray.j b/Foundation/CPArray.j index 566eb57bb..6f17532a9 100755 --- a/Foundation/CPArray.j +++ b/Foundation/CPArray.j @@ -602,6 +602,23 @@ objj_msgSend(self[index], aSelector, anObject); } +- (void)makeObjectsPerformSelector:(SEL)aSelector withObjects:(CPArray)objects +{ + if (!aSelector) + [CPException raise:CPInvalidArgumentException reason:"makeObjectsPerformSelector:withObjects: 'aSelector' can't be nil"]; + + var index = 0, + count = length, + argumentsArray = [nil, aSelector].concat(objects || []); + + for(; index < count; ++index) + { + argumentsArray[0] = self[index]; + objj_msgSend.apply(this, argumentsArray); + } +} + + // Comparing arrays /*! Returns the first object found in the receiver (starting at index 0) which is present in the