Next: Putting the button in Up: Adding a Button in Previous: A Quick Introduction to

Creating a Button

Creating a button is quite easy:
NSButton *myButton;

myButton = AUTORELEASE ([NSButton new]);
[myButton setTitle: @"Print Hello!"];
[myButton sizeToFit];
setTitle: sets the title (string) to be displayed on the button; sizeToFit resizes the button so that it fits the title it is displaying.

Next, we need to set target and action of the button:

[myButton setTarget: self];
[myButton setAction: @selector (printHello:)];
(self will refer to our custom object)



Nicola Pero 2000-07-29