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 7. Working with Collections > Storing Unordered Groups of Objects

Storing Unordered Groups of Objects

From: nsset.m

 6 NSArray *array = [NSArray arrayWithObjects:
 7   @"set", @"object", @"containing",
 8   @"seven", @"objects", @"not",
 9   @"eight", @"objects", nil];
10 NSSet *set = [NSSet setWithArray: array];
11 NSMutableSet *mSet = [set mutableCopy];
12 NSCountedSet *cSet =
13   [NSCountedSet setWithArray: array];

If you want to store a collection of objects without a defined order, you can use NSSet and its mutable subclass. This models a mathematical set, so inserting the same object twice will only store one copy of it.


  

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