Chapter 4. Storing data in collections
This chapter covers
Chapter 3 introduced the concept of object-oriented programming and demonstrated some of its advantages by using the services of the prebuilt NSString class, which provides common text manipulation and query-related functionality.
A large part of Foundation Kit is concentrated on the storage of data in collection data structures with names such as arrays, dictionaries, sets, and hashmaps. These data structures allow you to efficiently collect, group, sort, and filter data in a way that’s convenient for the application at hand. Discussing these commonly used classes is what this chapter is all about.
Let’s start by discussing how Foundation Kit improves upon a data structure you’re currently familiar with: a simple array.
The Rental Manager application, as it currently stands, stores a list of rental property details in a C-style array called properties. Inherently, nothing’s wrong with this technique, but it has some limitations. For example, when you declare a C-style array, you create it with a fixed number of elements, and it’s not possible to add or remove additional elements from the array without recompiling the application. Your rental management business may become more successful and require the ability to add new properties to the list at runtime.