When is NSEnumerator finished?
Posted
by samfu_1
on Stack Overflow
See other posts from Stack Overflow
or by samfu_1
Published on 2010-05-17T02:20:29Z
Indexed on
2010/05/17
2:30 UTC
Read the original article
Hit count: 174
nsenumerator
|cocoa
How do we know when enumeration is finished? The docs say: the return value of
nextObject
is nil when all objects have been enumerated. I was hoping to implement some "delegate-like" behavior whereby ...
if (nextObject == nil) {
do something because we're done!
}
But I see there is no such thing as:
enumerationDidFinish:
where in the following block could I check for the enumerator to be complete?
NSArray *anArray = // ... ;
NSEnumerator *enumerator = [anArray objectEnumerator];
id object;
while ((object = [enumerator nextObject])) {
// do something with object...
}
© Stack Overflow or respective owner