Outlet

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:

  1. 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.
  2. The app runs, and somehow this nib loads (in one of the ways I described in the previous section).
  3. Nib Object A is instantiated, and Nib Object B is instantiated. We now have an actual Dog instance and an actual Person instance.
  4. 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 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值