GUI is defined in the nib file.
Use interface builder to open nib file & design gui
define class used in the nib
IBOutlet
instance variable points to other object is called outlet
ex:
IBOutlet NSTextField *testField;
IBAction
the method is called by user interface objects
ex:
-(IBAction)seed:(id)sender;
create an object instance:
1. drag object from Library window to doc window
2. set its class to object's class name in the Identity Inspector
make connection:
connect two objects
ex:
a object has outlet textFiled of type TextField , then connect textFiled to TextFiled GUI
ex:
when button b is pressed, it calls the method test in object c. Then connect b to object c's methods test
awakeFromNib:
all objects are sent the message awakeFromNib after the objects in nib file are brought to life
Hence, we can do something in awakeFromNib to init GUI
沒有留言:
張貼留言