O'Reilly logo

Programming in Objective-C, Sixth Edition by Stephen G. Kochan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Set Objects

A set is a collection of unique objects, and it can be mutable or immutable. Operations include searching, adding, and removing members (mutable sets); comparing two sets; and finding the intersection and union of two sets.

In this section, we take a quick look at three set classes: NSSet, NSMutableSet, and NSIndexSet. We also mention the class NSCountedSet in passing so that you will know when you might need or want to use that set.

Program 15.19 shows some basic operations on sets. Suppose, for instance, that you want to display the contents of your sets several times during execution of the program. You therefore decide to create a new method called print. You add the print method to the NSSet class by creating a new category ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required