PDA

View Full Version : Value of a checkbox?




trey5498
Jun 20, 2008, 02:50 PM
I have used the IDE to assign a checkbox to an outlet to check its value.

However I can't figure out what to use for it. I have tried NSObject or NSButton because there is no NSCheckBox however I get warnings of: "Warning: 'NSObject' may not respond to 'isEqualToString.'"

Here is the Code:


header file:

NSObject *cse211djq

.m file

if([cse211djq isEqualToString:@"CSE-211-DJQ"] == YES) {




Where did I screw up? Eventually I will be setting it to an array which is for a later date.



Eraserhead
Jun 20, 2008, 02:56 PM
In the header file it should be IBOutlet NSButton *myCheckbox or whatever. Then you can link that up to the interface in Interface Builder.

Then in the implementation, you want to use if([myCheckbox state]==NSOnState) to see if the checkbox is checked or not.


PS Why have you used such rubbish un-Cocoa-like names for your stuff?

JNB
Jun 20, 2008, 02:58 PM
I'm not a programmer (and I'm about to prove it), but in most db's & such, particularly as read into spreadsheets that don't support the box, checkboxes are TRUE/FALSE conditions. Does that help any?

trey5498
Jun 20, 2008, 03:10 PM
That worked Thank you very very very much!!!

Eraserhead
Jun 20, 2008, 03:30 PM
I'm not a programmer (and I'm about to prove it), but in most db's & such, particularly as read into spreadsheets that don't support the box, checkboxes are TRUE/FALSE conditions. Does that help any?

In Cocoa they use YES and NO for true/false conditions normally, its just one of those things.

But in this case my answer is right :).

Darkroom
Jun 21, 2008, 12:51 AM
In Cocoa they use YES and NO for true/false conditions normally, its just one of those things.

But in this case my answer is right :).

or 0 and 1? isn't a bool a bool? can't we all just get along? :p