Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 8. Enumerators > Consequences

Consequences

Enumerators provide a consistent means of traversing a collection of objects independent of collection type and traversal algorithm. This decoupling allows a developer to change from one type of collection to another or choose different traversal algorithms without incurring the need to change all their collection traversal code.

In Cocoa, enumeration is implemented by subclassing NSEnumerator and by adopting the NSFastEnumeration protocol. In other frameworks, the role of an NSEnumerator is commonly called the Iterator pattern, though Enumerators can also act as a special case of the Strategy pattern by allowing a flexible choice of traversal algorithm.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial