xcode how to disable an nsbutton

Hello,


I am very new to xcode and I am simply trying to enable/disable an NSButton and I just can't seem to figure it out. Could smeone help me in this.


So just for a test I have a form with 2 buttons on it. I am clicking the button ConnectButton and expecting TestButton to become disabled. However tis never happens. I have tried many things but never get the TestButton to become disabled.


This is what I have so far:


In the .h file


@property (unsafe, nonatomic) IBOutlet NSButton *ConnectButton

@property (unsafe, nonatomic) IBOutlet NSButton *TestButton


In the .m file


Under the (IBAction)ConnectButton:9id)sender {


[ _TestButton setEnabled: NO ]

}


Thanks


Mike

You declared the outlets, but did you actually connect them? When you edit the .h file, is the little circle in the gutter to the left of the property declaration empty or filled?


Also, you can try logging the value of _TestButton in your action method. That will verify that it's being called and confirm whether the outlet is connected or not.


In IB, you can control drag from the controller which has the outlet to the button to connect the outlet.

Hello Ken, thank you for responding.


As I have indicated I am very very new to xcode so please be patient with my questions.


I have check the little circle beside the property of the button in th .h file, and no it is not filled. Now when you say :


In IB, you can control drag from the controller which has the outlet to the button to connect the outlet


I am not sure how to do this, or what IB means. I have a MainMenu.xib is this what you mean when you refer to IB.


So my files are:


ConnectTestAppDelegate.h

ConnectTestAppDelegate.m

MainMenu.xib


And some other files as well in SupportingFiles, etc.


Can you help me in respect to how I do this connection.


Thanks


Mike

Check this part of "getting stated" tutorial, it describes how to connect outlet:


https://developer.apple.com/library/mac/referencelibrary/GettingStarted/RoadMapOSX/books/RM_YourFirstApp_Mac/Articles/ConfiguringtheWindow.html#//apple_ref/doc/uid/TP40012262-TP40012101-CH3-SW5


You might want to read through this whole "Your first mac app" tutorial, it would take some of your time now but might save much more of your time later

Thank you,


I guess what I did wrong was I manually entered the @property for the button in the .h file and never realized that that did not connect it.


I deleted my initial @property, draged the button to the .h delegate file and and now it does work.


This form of coding is a bit different thn what I am used to so I am trying to get it all straight in my head.


Thanks


Mike

xcode how to disable an nsbutton
 
 
Q