forked from rentzsch/mogenerator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nsenumerate.h
30 lines (23 loc) · 1.2 KB
/
nsenumerate.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/****************************************************************************************
nsenumerate.h $Revision: 1.0 $
Copyright (c) 2003 Red Shed Software. All rights reserved.
by Jonathan 'Wolf' Rentzsch (jon at redshed dot net)
Wed Oct 8 2003 wolf: Created.
************************************************************************************/
#import <Foundation/Foundation.h>
#define nsenumerate_getEnumerator( TYPE, OBJ ) \
(TYPE)([OBJ isKindOfClass:[NSEnumerator class]] \
? OBJ \
: [OBJ performSelector:@selector(objectEnumerator)])
#define nsenumerate( CONTAINER, ITERATOR_TYPE, ITERATOR_SYMBOL ) \
for( ITERATOR_TYPE \
*enumerator = nsenumerate_getEnumerator(ITERATOR_TYPE*, CONTAINER), \
*ITERATOR_SYMBOL = [((NSEnumerator*) enumerator) nextObject]; \
ITERATOR_SYMBOL != nil; \
ITERATOR_SYMBOL = [((NSEnumerator*) enumerator) nextObject] )
#define nsenumerat( CONTAINER, ITERATOR_SYMBOL ) \
for( id \
enumerator = nsenumerate_getEnumerator(id, CONTAINER), \
ITERATOR_SYMBOL = [((NSEnumerator*) enumerator) nextObject]; \
ITERATOR_SYMBOL != nil; \
ITERATOR_SYMBOL = [((NSEnumerator*) enumerator) nextObject] )