Chapter 13. Working with Collections
In This Chapter
Learning to use collections
Understanding mutability versus immutability
Using specialized collections
Enumerating the members of a collection
Sorting and filtering collections
Using blocks with collections
While Foundation provides you with tons of classes for all kinds of purposes, it's worthwhile to visit a few of the most fundamental classes in depth because of the extent to which you are likely to use them in your applications.
Among those fundamental classes is the group of classes known as collections. A collection is a class which manages a group of objects. Every good language has a good collections API and Objective-C is no exception. The Foundation framework contains classes for dealing with arrays, dictionaries, hash tables, sets, and so on. These classes provide a comprehensive toolset for managing and manipulating groups of objects for almost any circumstance. Additionally, thanks to a small sprinkling of syntactical sugar as part of the language, dealing with enumerating, filtering, and sorting with these collection classes is simple and intuitive.
Working with Arrays
The first collection class that I want to introduce you to is NSArray
. The NSArray
class is used for managing an ordered collection of objects. An ordered collection of objects is a grouping of objects that is expected to be maintained in the order in which they were stored. Typically, an ordered collection of objects is accessed either through enumeration or ...
Get Objective-C now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.