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)

charlie D
charlie D
5,218 Points

yes

Alert views don't appear when I click on "sign up" or "login" without entering login or sign up info. I'm using Xcode 5 - not getting any error messages. Any suggestions?

My code is listed below:


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

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

    [alertview show];
    

    }

} @end

obey me
obey me
1,135 Points

This is a shorter way to do it,I hope it helps

             (IBAction)signup:(id)sender
                 { 
                 if ([username.text isEqualToString@""]||[password.text isEqualToString ""]||[email.text isEqualToString""]){

                      UIAlertView *alertview = [[UIAlertView alloc] initWithTitle:@"O0ps!" message:@"Make sure you enter a username, password and email address!" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];

                           [alertview show];

                }
              else{

            // do whatever you want there 
             }

1 Answer

Anthony Rouinvy
Anthony Rouinvy
10,495 Points

I can't tell you why it doesn't work, but, I took your code, created a new project on XCode 6, iPhone 6 simulator and it does work.