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 trialNatacha S
11,561 Pointscode 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
Stephen Whitfield
16,771 PointsDepends on what error you're getting. Could you post the error?
Natacha S
11,561 Pointsthis is the error i get : Bummer! Compilation Error! This syntax is a little tricky. Refer to the example in the video for help!
Stephen Whitfield
16,771 PointsWhat 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?
Natacha S
11,561 Pointsthis 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.
Stephen Whitfield
16,771 PointsEverything looks fine to me. I don't know why it's not passing.
Stone Preston
42,016 PointsHmm try putting your if statement below the BOOL isCorrect = blah blah statement instead of before it
Stephen Whitfield
16,771 PointsThe 'if' statement is part of the 'makeGuess' function.
Stephen Whitfield
16,771 PointsActually try putting the BOOL isCorrect declaration inside your function after your NSString declaration.
Natacha S
11,561 Pointsit finally passed...what was missing was the second closing bracket :-/
Stephen Whitfield
16,771 PointsOh 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. ^_^
Stephen Whitfield
16,771 PointsJust 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.
Natacha S
11,561 Pointsthanks !