Uh...what

Discussion in 'iOS Development' started by psychofish25, Apr 22, 2009.

  1. psychofish25

    psychofish25 New Member

    Joined:
    Nov 20, 2007
    Messages:
    259
    Likes Received:
    3
    I really don't know why this program will not work. I have everythign set up correctly and it runs fine.

    -(IBAction)unlock: (id) sender {
    NSString *text = @"Locked";
    if (password.text == @"1")
    {
    text = @"Unlocked!";
    }

    status.text = text;

    [text release];
    }

    When I type 1 into the password text box. The label still outputs "Locked." Can someone please tell me what it wrong with my if statement?

    Thanks
  2. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    password.text == @"1" will always return NO. You can't check for equality in NSStrings like that.

    Instead, use if ([password.text isEqualToString

    Please Register or Log in to view images

    "1"])
  3. psychofish25

    psychofish25 New Member

    Joined:
    Nov 20, 2007
    Messages:
    259
    Likes Received:
    3
    Awesome, thanks.

Share This Page