mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 09:41:15 +00:00
Added -enumerateObjectsUsingBlock: implementation to NSArray.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@29174 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a197590f24
commit
23b31db6b3
3 changed files with 24 additions and 0 deletions
|
@ -29,6 +29,7 @@
|
||||||
#import <Foundation/NSObject.h>
|
#import <Foundation/NSObject.h>
|
||||||
#import <Foundation/NSRange.h>
|
#import <Foundation/NSRange.h>
|
||||||
#import <Foundation/NSEnumerator.h>
|
#import <Foundation/NSEnumerator.h>
|
||||||
|
#import <GNUstepBase/GSBlocks.h>
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -115,6 +116,14 @@ extern "C" {
|
||||||
- (BOOL) writeToURL: (NSURL*)url atomically: (BOOL)useAuxiliaryFile;
|
- (BOOL) writeToURL: (NSURL*)url atomically: (BOOL)useAuxiliaryFile;
|
||||||
- (id) valueForKey: (NSString*)key;
|
- (id) valueForKey: (NSString*)key;
|
||||||
#endif
|
#endif
|
||||||
|
DEFINE_BLOCK_TYPE(GSEnumeratorBlock, void, id, NSUInteger, BOOL*);
|
||||||
|
/**
|
||||||
|
* Enumerate over the collection using the given block. The first argument is
|
||||||
|
* the object and the second is the index in the array. The final argument is
|
||||||
|
* a pointer to a BOOL indicating whether the enumeration should stop. Setting
|
||||||
|
* this to YES will interrupt the enumeration.
|
||||||
|
*/
|
||||||
|
- (void)enumerateObjectsUsingBlock: (GSEnumeratorBlock)aBlock;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -112,6 +112,7 @@ win32-def.top \
|
||||||
libgnustep-base.def
|
libgnustep-base.def
|
||||||
|
|
||||||
ADD_HEADERS = \
|
ADD_HEADERS = \
|
||||||
|
GSBlocks.h \
|
||||||
GSVersionMacros.h \
|
GSVersionMacros.h \
|
||||||
GSObjCRuntime.h \
|
GSObjCRuntime.h \
|
||||||
GSCategories.h \
|
GSCategories.h \
|
||||||
|
|
|
@ -54,6 +54,7 @@
|
||||||
#import "Foundation/NSKeyedArchiver.h"
|
#import "Foundation/NSKeyedArchiver.h"
|
||||||
#import "GNUstepBase/GSCategories.h"
|
#import "GNUstepBase/GSCategories.h"
|
||||||
#import "GSPrivate.h"
|
#import "GSPrivate.h"
|
||||||
|
#import "GSFastEnumeration.h"
|
||||||
|
|
||||||
static BOOL GSMacOSXCompatiblePropertyLists(void)
|
static BOOL GSMacOSXCompatiblePropertyLists(void)
|
||||||
{
|
{
|
||||||
|
@ -1618,6 +1619,19 @@ compare(id elem1, id elem2, void* context)
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
- (void)enumerateObjectsUsingBlock: (GSEnumeratorBlock)aBlock
|
||||||
|
{
|
||||||
|
NSUInteger count = 0;
|
||||||
|
BOOL shouldStop = NO;
|
||||||
|
FOR_IN (id, obj, self)
|
||||||
|
CALL_BLOCK(aBlock, obj, count++, &shouldStop);
|
||||||
|
if (shouldStop)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
END_FOR_IN(self)
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue