April 2015
Intermediate to advanced
556 pages
17h 47m
English
Objects are often arranged in a network. For example, a person might have a spouse who has a scooter that has a model name (Figure 8.14).
Figure 8.14 Directed graph of objects
To get the selected person’s spouse’s scooter’s model name, you can use a key path:
let modelName = selectedPerson.valueForKeyPath("spouse.scooter.modelName") as String
We would say that spouse and scooter are relationships of the Person class and that modelName is an attribute of the Scooter class.
There are also operators that you can include in key paths. For example, if you have an array of Person objects, you ...
Read now
Unlock full access