Return to the Alphabetic Index
Return to the Class Browser
Return to the Picture Browser
Copyright (c) 1994 by NeXT Computer, Inc. All Rights Reserved.

NSEnumerator

Inherits From: NSObject

Conforms To: NSObject (NSObject)

Declared In: Foundation/NSUtilities.h

Class Description

NSEnumerator is a simple abstract class whose instances enumerate collections of other objects. Collection objectssuch as NSSets, NSArrays, and NSDictionariesprovide NSEnumerator objects that can traverse their contents. You send nextObject repeatedly to an NSEnumerator to have it return the next object in the collection. When there are no more objects to return, nextObject returns nil.

Collection classes include methods that return an enumerator appropriate to the type of collection. NSArray has two methods that return an NSEnumerator object, objectEnumerator and reverseObjectEnumerator (the former traverses the array starting at its first object, while the latter starts with the last object and continues backward through the array to the first object). NSSet's objectEnumerator provides an enumerator for sets. NSDictionary has two enumerator-providing methods: keyEnumerator and objectEnumerator.

Note: Collections shouldn't be modified during enumeration. NSEnumerator imposes this restriction to improve enumeration speed.

Traversing a Collection