Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Luke Schoen
Luke Schoen
3,317 Points

Help with Code Challenge: Signing Up new Users

Hi there,

I am attempting to answer Challenge Task 3 of 4, but it is saying my answers are wrong. I have even tested the code in my app and it works.

Note that I have also tried the following alternative comparison without success as well: [isCorrect isEqualToString:(NSString *) @"YES"]

Question and my attempted Answer is shown below. Help much appreciated.

Challenge Question:

Challenge task 3 of 4 If the guess is correct, we want to alert the user with a message using a UIAlertView. Add an if statement that checks if the BOOL variable 'isCorrect' is true (or 'YES'). Inside the if statement, declare a new UIAlertView variable named 'alertView'. Alloc/init it with the method 'initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles'. For the title, use "Hooray!", for the message, use "You did it!", for the delegate use nil, for cancelButtonTitle use "OK", and for otherButtonTitles use nil.

My Answer:

@implementation NumberGuesserViewController

  • (IBAction)makeGuess:(id)sender { NSString *userNumber;

    userNumber = self.numberField.text;

    // Check to see if the user's number is correct BOOL isCorrect = [GuessEngine testGuess:userNumber];

    if (isCorrect == true || [isCorrect isEqual:@"YES"]) { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Hooray!" message:@"You did it!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];

    [alertView show]; }
    }

Regards,

Luke

Luke Schoen
Luke Schoen
3,317 Points

Confusing question, but I ended up getting the right answer. I just removed the following code and it worked:

|| [isCorrect isEqual:@"YES"]

4 Answers

Agreed, it could be helpful to others, it was just showing as unanswered, so others may not have known you found a solution.

Luke Schoen
Luke Schoen
3,317 Points

Well you've taken an important action in identifying the gap for closeout and therefore worthy of the best answer. Thanks for reading!

Luke,

Do you know if there a way once you get an answer to close the post?

Luke Schoen
Luke Schoen
3,317 Points

No, I don't know. I just left my question and answer because it caused me some grief and it might help someone else out.

Also not helpful...

This thread should be marked "iOS" so it comes up in the iOS searches: https://teamtreehouse.com/forum/topic:ios

..instead of for coding the Android version of Ribbit.

oscar gonzalez
oscar gonzalez
7,072 Points

this was my answer it worked for me // Check to see if the user's number is correct BOOL isCorrect = [GuessEngine testGuess:userNumber]; if(isCorrect==true || isCorrect==YES){ UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Hooray!" message:@"You did it!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; }