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 Build a Self-Destructing Message iPhone App Using Parse.com as a Backend and Adding Users Signing Up New Users: Part 1 (UIAlertView)

Damian Bednarz
Damian Bednarz
3,597 Points

send message to the 'alertView' to show it to the user

Hi everyone

Sorry for my nooby question but i really don't understand what should i do in this step ?

How to send a message to the 'alertView' to show it to the user ??

NumberGuesserViewController.h
#import "UIViewController.h"
#import "UITextField.h"

@interface NumberGuesserViewController : UIViewController

@property (strong, nonatomic) IBOutlet UITextField *numberField;

- (IBAction)makeGuess:(id)sender;

@end
NumberGuesserViewController.m
#import "NumberGuesserViewController.h"
#import "GuessEngine.h"
#import "UIAlertView.h"

@implementation NumberGuesserViewController

- (IBAction)makeGuess:(id)sender {
     NSString *userNumber = self.numberField.text;

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


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

@end

2 Answers

Lee Watkins
Lee Watkins
11,345 Points

Hi Damian Bednarz

When they say "send a message", what they mean is "tell the UIAlertView object to display the alert that it contains". In this case, that means adding the line

[alertView show];

which you have already added. The previous stage only needed you to create the variable, and this final stage is where you are required to show the message.

You should be able to just click "Check Work" and your code should work.

Regards, UniekLee

Damian Bednarz
Damian Bednarz
3,597 Points

You right :) Thanks. I just put in step 3 also answer from step 4 and fix my mind that i need write something and never try press check work without add something at step 4 :)

Patrick Cooney
Patrick Cooney
12,216 Points

If you're familiar with other programming languages, another way to put it is that you are calling a method. Objective-C uses the term "message sending" to mean the same thing as "calling a method" in other languages.