Configure a button added in IB
-
Am a quite a newbie to Cocoa programming.
Adding and configuring a button in IB is straightforward. I understand
the process of setting action and target in IB and the connection to
Xcode (IBOutlet and IBAction).
But what is the approach when creating a button in IB that I then want
to configure (set title, image, enabled, etc.) in Xcode? How do I
reach the button from Xcode?
wamund -
To do it from code, add something like..
IBOutlet NSButton *theButton;
...to your .h
Instanitate your class in interface builder and then connect theButton
to your button my control dragging from your class to the button.
and then use the documentation here: http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Cla
sses/NSButton_Class/Reference/Reference.html
...to learn what kind of messages you can send to it.
ex. [theButton setTitle:@"send steve money"];
:-)
Good luck,
Steven Riggs
On Nov 15, 2008, at 7:04 PM, Mikael Wämundson wrote:> Am a quite a newbie to Cocoa programming.
> Adding and configuring a button in IB is straightforward. I
> understand the process of setting action and target in IB and the
> connection to Xcode (IBOutlet and IBAction).
> But what is the approach when creating a button in IB that I then
> want to configure (set title, image, enabled, etc.) in Xcode? How do
> I reach the button from Xcode?
>
> wamund -
Thanks! Works like a charm.
Didn't work at first because I put
theButton = [[NSButton alloc] init];
before the
[theButton setTitle:@"send steve money"];
When that was removed, it worked ok (and you will probably get your
money).
wamund
16 nov 2008 kl. 02.48 skrev Steven Riggs:> To do it from code, add something like..
> IBOutlet NSButton *theButton;
> ...to your .h
>
> Instanitate your class in interface builder and then connect
> theButton to your button my control dragging from your class to the
> button.
>
> and then use the documentation here: http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Cla
sses/NSButton_Class/Reference/Reference.html
>
> ...to learn what kind of messages you can send to it.
>
> ex. [theButton setTitle:@"send steve money"];
>
> :-)
>
> Good luck,
> Steven Riggs
>
> On Nov 15, 2008, at 7:04 PM, Mikael Wämundson wrote:
>
>> Am a quite a newbie to Cocoa programming.
>> Adding and configuring a button in IB is straightforward. I
>> understand the process of setting action and target in IB and the
>> connection to Xcode (IBOutlet and IBAction).
>> But what is the approach when creating a button in IB that I then
>> want to configure (set title, image, enabled, etc.) in Xcode? How
>> do I reach the button from Xcode?
>>
>> wamund
>
>


