[help]how to dealing with checkbox in Xcode

Joined
Feb 24, 2009
Messages
2
Reaction score
0
Points
1
hello everyone,

i search in deferent book about how to dealing with the checkbox but i don`t understood it

so can anyone help me.. and tell me how to dealing with it..?
how to know if it true or false..?

and please if you have a good website tutorial send the link to me or write it here..
 
Joined
Jul 11, 2009
Messages
1
Reaction score
0
Points
1
Well, the checkbox in Interface Builder is really just a type of NSButton, and in Xcode's documentation, it tells us a button can have either two or three states, On (true), Off (false) and sometimes Mixed.

Now, how do we find out what state the button is in? First, create an connection between your code and your NIB with this.
Code:
IBOutlet NSButton *buttonName;

Then, in your code, you can use a simple if statement to fine out what state the button is in, like so.

Code:
if ( [button state] == NSOnState ) {
    //The button is checked...
} else {
    //The button is not checked...
}

You can see a very simple example in the attached project. Open the Console and when you press Update, you'll see if the button is on or not.

View attachment CheckTest.zip
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top