outlet,target,action

an outlet is an instance that stores a reference (pointer) to another object such as a user interface object.

The IBOutlet macro is defined in NSNibDeclarations.h, which is part of Cocoa's application kit framework, and c preprocessor replaces it with a single space character whenever it's encountered in source code.

Interface Builder stores information  about connections from outlets to other objects using a class called NSNibOutletConnector. When objects are loaded from a .nob file into a running application, any loaded NSNibOutletConnector instances automatically receive an -establishConnection message, which directs them to assigning the values of associated outlet instance variables.

After all objects have been loaded and initialized from a .nib file, an -awakeFromNib message is sent to each object that was loaded. By the time an object receives the -awakeFromNib message, all of its outlets have been set to the values they were given in interface builder.

The -awakeFromNib message is also sent to the object that is specified as the “owner” of the nib when the .nib file is loaded. Caution is needed when implementing Accessor methods for objects that may be loaded from a .nib file.Accessor methods are called whenever possible as .nib files are loaded, but the order in which objects are loaded from the .nib file is undefined.

 

Cocoa’s NSControl, NSActionCell, and NSMenuItem classes each provide an outlet named target and a corresponding instance variable named action.

 

Any method that returns void and accepts one object argument can be used as an action.

 

posted on 2012-07-08 11:42  grep  阅读(260)  评论(0编辑  收藏  举报