Outlet Connections
You know how to load a nib file, thus instantiating its top-level nib objects. But those instances are useless to you if you don’t know how to get a reference to any of them in your code. To refer in code to instances generated from nib objects when the nib loads, you need an outlet connection from a proxy object in the same nib.
A connection is a named unidirectional linkage from one object in a nib file (the connection’s source) to another object in the same nib file (the connection’s target). An outlet is a connection whose name corresponds to an instance variable in the source object. When the nib loads, and the target object is instantiated, the value of the instance variable is set to the target object. Thus the source object winds up with a reference to the target object as the value of one of its instance variables.
Connections can link any two objects in a nib file, but a proxy object as the source of a connection is special because it represents an object that exists before the nib loads. Thus an outlet from a proxy object causes an object that exists before the nib loads to end up with an instance variable whose value is an object that doesn’t exist until after the nib loads — an object that is in fact instantiated by the loading of the nib.
In the most typical configuration, the proxy object will be the File’s Owner. The instance that owns the nib has an instance variable, and the File’s Owner in the nib has a corresponding outlet to a nib object; the ...
Get Programming iOS 4 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.