DekGenius.com
[ Team LiB ] Previous Section Next Section

NSEnumerator Mac OS X 10.0

This class enumerates the contents of a collection. Instances of this class are created by the collection classes, generally with the method objectEnumerator. NSArray declares the method reverseObjectEnumerator, and NSDictionary declares keyEnumerator as additional methods that create instances of NSEnumerator.

To obtain the next object in an enumerator, we invoke the method nextObject. This will return an object, and advance the enumerator position forward in the collection. When the enumerator has exhausted the collection, nextObject returns nil. Enumerators cannot be reset; once you have enumerated a collection, you must obtain an new enumerator from the collection to start again. The method allObjects is used to return an NSArray of the objects that have not yet been enumerated. See Chapter 2 for more information on collections and enumerators.

figs/cocn_1336.gif

@interface NSEnumerator : NSObject
 // Instance Methods
   - (NSArray *)allObjects;
   - (id)nextObject;

Subclasses

NSDirectoryEnumerator

    [ Team LiB ] Previous Section Next Section