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

General Discussion

code challenge : signing up new users part1

what's wrong with my code ?

@implementation NumberGuesserViewController

- (IBAction)makeGuess:(id)sender {
    NSString *userNumber=self.numberField.text;
    if (isCorrect == YES)
    {UIAlertView *alertView = [[UIAlertView alloc]
    initWithTitle:@"Hooray!" message:@"You did it!" delegate:nil
    cancelButtonTitle:@"OK" otherButtonTitles: nil];
    };
    // Check to see if the user's number is correct
    BOOL isCorrect = [GuessEngine testGuess:userNumber];


@end

10 Answers

Depends on what error you're getting. Could you post the error?

this is the error i get : Bummer! Compilation Error! This syntax is a little tricky. Refer to the example in the video for help!

What is the quiz asking you to do? Have you checked the syntax with the syntax in the video it's talking about to make sure it's what they're looking for?

this is the question: 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.

Everything looks fine to me. I don't know why it's not passing.

Stone Preston
Stone Preston
42,016 Points

Hmm try putting your if statement below the BOOL isCorrect = blah blah statement instead of before it

The 'if' statement is part of the 'makeGuess' function.

Actually try putting the BOOL isCorrect declaration inside your function after your NSString declaration.

it finally passed...what was missing was the second closing bracket :-/

Oh man! Hate when that happens! I checked for that as well, but I guess not thoroughly enough (I was at work while trying to help you out). I mistook the bracket closing your 'if' statement as the bracket closing the function. ^_^

Just an FYI, if you have Xcode or SublimeText, what you could try next time is copying and pasting that code into a blank file that interprets Objective-C. That way you'll know the syntactical errors in your code.

thanks !