From 1c6738c6607fdd9dc935ec8f337d606e6937252e Mon Sep 17 00:00:00 2001 From: fredkiefer Date: Fri, 13 Dec 2013 21:01:22 +0000 Subject: [PATCH] * Headers/Foundation/NSArray.h, * Source/NSArray.m: Move -setValue:forKey: from NSMutableArray to NSArray. Patch by Marcian Lytwyn . git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37464 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 7 +++++++ Headers/Foundation/NSArray.h | 4 +--- Source/NSArray.m | 36 ++++++++++++++++++------------------ 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index de31797af..00bb3d648 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2013-12-13 Fred Kiefer + + * Headers/Foundation/NSArray.h, + * Source/NSArray.m: Move -setValue:forKey: from NSMutableArray to + NSArray. + Patch by Marcian Lytwyn . + 2013-12-07 Wolfgang Lux * Source/Additions/Unicode.m (GSPrivateDefaultCStringEncoding): diff --git a/Headers/Foundation/NSArray.h b/Headers/Foundation/NSArray.h index b65366178..dd3c17db1 100644 --- a/Headers/Foundation/NSArray.h +++ b/Headers/Foundation/NSArray.h @@ -152,6 +152,7 @@ typedef NSUInteger NSBinarySearchingOptions; #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) - (BOOL) writeToURL: (NSURL*)url atomically: (BOOL)useAuxiliaryFile; - (id) valueForKey: (NSString*)key; +- (void) setValue: (id)value forKey: (NSString*)key; #endif #if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) @@ -377,9 +378,6 @@ DEFINE_BLOCK_TYPE(GSPredicateBlock, BOOL, id, NSUInteger, BOOL*); - (void) sortWithOptions: (NSSortOptions)options usingComparator: (NSComparator)comparator; #endif -#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) -- (void) setValue: (id)value forKey: (NSString*)key; -#endif /** * Set method called by the compiler with array subscripting. */ diff --git a/Source/NSArray.m b/Source/NSArray.m index 3ed805ac6..0a4bd194e 100644 --- a/Source/NSArray.m +++ b/Source/NSArray.m @@ -1731,6 +1731,24 @@ compare(id elem1, id elem2, void* context) return result; } +/** + * Call setValue:forKey: on each of the receiver's items + * with the value and key. + */ +- (void) setValue: (id)value forKey: (NSString*)key +{ + unsigned i; + unsigned count = [self count]; + volatile id object = nil; + + for (i = 0; i < count; i++) + { + object = [self objectAtIndex: i]; + [object setValue: value + forKey: key]; + } +} + - (void) enumerateObjectsUsingBlock: (GSEnumeratorBlock)aBlock { [self enumerateObjectsWithOptions: 0 usingBlock: aBlock]; @@ -2552,24 +2570,6 @@ compare(id elem1, id elem2, void* context) { [self sortWithOptions: 0 usingComparator: comparator]; } - -/** - * Call setValue:forKey: on each of the receiver's items - * with the value and key. - */ -- (void) setValue: (id)value forKey: (NSString*)key -{ - unsigned i; - unsigned count = [self count]; - volatile id object = nil; - - for (i = 0; i < count; i++) - { - object = [self objectAtIndex: i]; - [object setValue: value - forKey: key]; - } -} @end @implementation NSArrayEnumerator