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)

Esma Goktekin
Esma Goktekin
3,870 Points

alertView does not pop up

I followed the instructions in the video. However when I click on the button signup it does not show the alerView.

Here is my code in SingupViewController.m

- (IBAction)signup:(id)sender {
    NSString *username = [self.usernameField.text stringByTrimmingCharactersInSet:
                          [NSCharacterSet whitespaceAndNewlineCharacterSet]];
    NSString *passcode = [self.passcodeField.text stringByTrimmingCharactersInSet:
                          [NSCharacterSet whitespaceAndNewlineCharacterSet]];
    NSString *email = [self.emailField.text stringByTrimmingCharactersInSet:
                       [NSCharacterSet whitespaceAndNewlineCharacterSet]];

    if ([username length] == 0 || [passcode length] == 0 || [email length] == 0) {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oops!" 
message:@"Make sure you enter a username, passcode and email address" 
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];

[alertView show];
    }

What might be wrong? Any help would be appreciated

8 Answers

Esma Goktekin
Esma Goktekin
3,870 Points

Problem Solved!! Following methods were commented out in my InboxViewController.m when I first opened. I did not noticed they were not commented out in the video.

  • (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{}

  • (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{}

Great, glad you figured it out!

Misha Shaposhnikov
Misha Shaposhnikov
8,718 Points

Try changing the delegate of alertView from nil to self.

Misha Shaposhnikov
Misha Shaposhnikov
8,718 Points

Are you sure the username, password, and email fields have text in them when you call this fucntion?

Esma Goktekin
Esma Goktekin
3,870 Points

yes they have text in them : username, passcode and email adress..

Misha Shaposhnikov
Misha Shaposhnikov
8,718 Points

Well, the only thing I can think of now is: making sure you connected this IBAction to the correct ViewController in the Storyboard?

Esma Goktekin
Esma Goktekin
3,870 Points

I double checked that too.. This is so annoying.. But thanks anyways

Just delete the alert view, clean it (Command + Shift + K), quit xcode, and reopen it. Then rewrite the alert view. Maybe that will work!

And when you use caveman debugging (NSLog at the top of the action with some call out to let you know that the action is actually being called), you do in fact, see something?

Your code as posted looks fine to me.

Faisal Alsheikh
Faisal Alsheikh
8,841 Points

Did you check if your button is connected to IBAction? connecting it by holding down on the button in story board then pressing Ctrl and dragging to your SingupViewController.h. also make sure that signup scene custom class is set to SignupViewController

Esma Goktekin
Esma Goktekin
3,870 Points

Yes I checked those, everything looks alright

Can you please post your project or github or Dropbox? That way, we can take a look.