# "If", a string, and NSTextField in Cocoa



## rhale1 (Dec 7, 2001)

*Code included below:

I want my if statement to check if the regiterField is equal to the string (declared with NSString, red when used in the 'if' statement). How do I get them to agree?


```
- (IBAction)registerAction:(id)sender
{
    NSString *code = @"dxs-ce-01-12345";
    
    if ([[registerField stringValue] [COLOR=crimson]code[/COLOR]])
    {
    }
}
```


----------



## Ghoser777 (Dec 7, 2001)

I think u need to do some more wonk on your own.  If you've installed the developer CD, all the documentation is stored in /Developer/Documentation/Cocoa/Reference  Just look at the NSString docs in the reference section; it's painfully obvious.

Just trying to kick you in the right direction,
F-bacher


----------



## cthulhu (Dec 21, 2001)

you can use :

- (IBAction)registerActionid)sender
{
    NSString *code = @"dxs-ce-01-12345";

    if ([[registerField stringValue] isEqualToString:code])
    {
         do something here....
    }
}


----------



## Ghoser777 (Dec 23, 2001)

Well, if you just go ahead and tell him, how is he/she ever going to learn? 

F-bacher


----------



## cthulhu (Dec 24, 2001)

I have learn the obj C ...and cocoa..only using the "Developper help center".....if you nedd help....email me...
cthulhu77@libero.it....(i will try to answer) 

PS: excuse me for my english ..i'm italian...


----------



## slur (Jan 9, 2002)

*Well, if you just go ahead and tell him, how is he/she ever going to learn?*

By repeatedly making use of what he was told!


----------

