When does NSEnumerator end?
How do we know when the listing is complete? The docs say: return value
nextObject
equals zero when all objects have been listed. I was hoping to implement some "delegate-like behavior" resulting in ...
if (nextObject == nil) {
do something because we're done!
}
But I see that there is no such thing as:
enumerationDidFinish:
where in the next block I can check the completion of the enumerator?
NSArray *anArray = // ... ;
NSEnumerator *enumerator = [anArray objectEnumerator];
id object;
while ((object = [enumerator nextObject])) {
// do something with object...
}
+2
a source to share
5 answers