Value of a checkbox?

Discussion in 'Mac Programming' started by trey5498, Jun 20, 2008.

  1. macrumors regular

    Joined:
    Jun 16, 2008
    #1
    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:

    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.
     
  2. macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #2
    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?
     
  3. JNB
    macrumors 604

    JNB

    Joined:
    Oct 7, 2004
    Location:
    In a Hell predominately of my own making
    #3
    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?
     
  4. thread starter macrumors regular

    Joined:
    Jun 16, 2008
    #4
    That worked Thank you very very very much!!!
     
  5. macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #5
    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 :).
     
  6. Guest

    Darkroom

    Joined:
    Dec 15, 2006
    Location:
    Montréal, Canada
    #6
    or 0 and 1? isn't a bool a bool? can't we all just get along? :p
     

Share This Page