An outlet is something in a nib file: it’s a connection from one object in a nib file to another.
For example, let’s say that we’ve made a nib where the class of Nib Object A is Dog, and let’s say that a Dog has a master instance variable, which is typed as a Person. And let’s say that the class of Nib Object B is Person. Then:
- Let’s say that in the nib editor, you draw an outlet connection from Nib Object A (a potential Dog instance) to Nib Object B (a potential Person instance) — an outlet called master. This connection is now part of the nib.
- The app runs, and somehow this nib loads (in one of the ways I described in the previous section).
- Nib Object A is instantiated, and Nib Object B is instantiated. We now have an actual Dog instance and an actual Person instance.
- But the nib-loading mechanism is not finished. It sees that the nib also contains an outlet from Nib Object A to Nib Object B, called master. Accordingly, it calls setValue:forKey: on the Dog instance, where the key is @"master" and the value is the Person instance. Presto, the Dog instance now has a reference to the Person instance — namely, as the value of its master instance variable!
To sum up: an outlet in the nib is just a name involving two potential objects. But when the nib is loaded, the nib-loading mechanism makes those objects real, and it turns that outlet into an actual reference from one object to the other by way of an instance variable