Accessing and Modifying a Dictionary
Now that you have a mutable dictionary, how do you work with it? You will want to read from and modify the dictionary. Begin by using count to get some useful information about your dictionary.
Listing 10.2 Using
import Cocoa var movieRatings = ["Donnie Darko": 4, "Chungking Express": 5, "Dark City": 4] print("I have rated \(movieRatings.count) movies.")
count is a read-only property on the Dictionary type that keeps track of how many instances are held within the dictionary instance itself. We will discuss properties in detail in Chapter 16 ...